BTC Futures BasisShows various basis percentages in a table and plots historical basis. Also has an alert function for backwardation events. Useful for tracking bullish/bearish sentiment in BTC futures markets.
*Currently displays March and June futures for the following exchanges: Bitmex, Binance, Deribit, Okex, and FTX
Also displays CME Continuous Next Contract. All of the symbols are customizable.
-----------
Market-wide backwardation usually occurs during a heavy sell-off (such as a liquidation cascade).
**For getting alerts of backwardation events, I recommend creating an alert on the 1 minute chart with the condition "Any alert() function call". Alert level is customizable as well.
-----------
*NOTE!! : Futures contracts expire (obviously), so the contract symbols will need to be updated periodically. I will try to keep them updated going into the future.
**NOTE2!! : The alert() function does not track the CME contract. This is to avoid false triggers.
חפש סקריפטים עבור " TABLE"
SPY Sub-Sector Daily Money Flow TableThis calculates the dollar volume per candlestick (2nd row) and cumulative (3rd row) of the entire trading day for each subsector of the SPY.
The 'Total' column is the total of all the subsectors combined. It is calculated separately from SPY volume.
The money flow is calculated with (open+close)/2 which means different timeframes yield different results and won't be especially accurate day-by-day. This is useful to quickly see rotation and possible divergences.
Enjoy!
PreMarketStatsThe idea is to catch pre market information (or other relevant data), that basically consists of a single number, in a table instead of using a plot that takes up space in the chart. In this example, I added pre market volume and pre market change in %. Where the second one is as well available in the details tab of the stock, it is not available if this tab is closed or during replays.
[CLX][#01] Animation - Price Ticker (Marquee)This indicator displays a classic animated price ticker overlaid on the user’s current chart. It is possible to fully customize it or to select one of the predefined styles.
A detailed description will follow in the next few days.
Used Pinescript technics:
- varip (view/animation)
- tulip instance (config/codestructur)
- table (view/position)
By the way, for me, one of the coolest animated effects is by Duyck
We hope you enjoy it! 🎉
CRYPTOLINX - jango_blockchained 😊👍
Disclaimer:
Trading success is all about following your trading strategy and the indicators should fit within your trading strategy, and not to be traded upon solely.
The script is for informational and educational purposes only. Use of the script does not constitute professional and/or financial advice. You alone have the sole responsibility of evaluating the script output and risks associated with the use of the script. In exchange for using the script, you agree not to hold dgtrd TradingView user liable for any possible claim for damages arising from any decision you make based on use of the script.
Probability TableThe script is inspired by user NickbarComb, I suggested checking out his Price Convergence script.
Basically, this script plots a table containing the probability of the current candle closing either higher or lower based on user-define past period.
Hope that it will be helpful.
MTF Price/Volume % [Anan]Hello friends,
This is a multi-timeframe table with these features:
Display price change percentage compared with the last timeframe candle close.
Display price change percentage compared with the last timeframe candle close MA.
Displays change percentage compared with the last timeframe candle volume.
Displays change percentage compared with the last timeframe candle volume MA.
Change type/length of MA for Price/Volume.
Full control of Panel position and size.
Full control of displaying any row or column.
Average Daily Range TableThis is the last script to complete Vladimir Poltoratskiy's setup found in his books.
Poltoratskiy argues that you should not take any fractal corridors higher than 50% of the Average Daily Range. To be honest, even 40% is a lot, because then, your target will be 160% ADR away from your entry and one "fracture" just can't be enough to predict moves this big.
I chose a table to visually represent the indicator because it doesn't change its value during the day. It takes far less room on the chart.
There are also two simple moving averages. You may use the as an indicator if the relative volatility as of late is extremely low and in that case, perhaps, expect an increase in the coming days. They are applied to the Average Daily Range, not one day range!
PAC newThis indicator will alert you when a candle goes above or below the price action channel (PAC) but only on the first or second candle after a colour change in candle.
When price is above the price action channel that is a bullish sign, when price is below the PAC that is a bearish sign.
The idea is that a sudden change in price is a cause to investigate further price action moving in that direction so the indicator aims to identify reversal
Scalping strategy that works on 5 min chart and aims to gain 10 pips. Do not act on every signal. Further investigation is required, for example by looking at RSI oversolf and overbought levels. For example, at an oversold area, a buy signal is more valid
Table: Forex Central Bank Interest RatesThis tool shows CB Interest Rates for USD, JPY, CAD, CHF, EUR, GBP, NZD, AUD - basically all the majors.
Use override and input your own value if it is changed and I haven't updated the script yet.
Month/Month Percentage % Change, Historical; Seasonal TendencyTable of monthly % changes in Average Price over the last 10 years (or the 10 yrs prior to input year).
Useful for gauging seasonal tendencies of an asset; backtesting monthly volatility and bullish/bearish tendency.
~~User Inputs~~
Choose measure of average: sma(close), sma(ohlc4), vwap(close), vwma(close).
Show last 10yrs, with 10yr average % change, or to just show single year.
Chose input year; with the indicator auto calculating the prior 10 years.
Choose color for labels and size for labels; choose +Ve value color and -Ve value color.
Set 'Daily bars in month': 21 for Forex/Commodities/Indices; 30 for Crypto.
Set precision: decimal places
~~notes~~
-designed for use on Daily timeframe (tradingview is buggy on monthly timeframe calculations, and less precise on weekly timeframe calculations).
-where Current month of year has not occurred yet, will print 9yr average.
-calculates the average change of displayed month compared to the previous month: i.e. Jan22 value represents whole of Jan22 compared to whole of Dec21.
-table displays on the chart over the input year; so for ES, with 2010 selected; shows values from 2001-2010, displaying across 2010-2011 on the chart.
-plots on seperate right hand side scale, so can be shrunk and dragged vertically.
-thanks to @gabx11 for the suggestion which inspired me to write this
Koalafied Risk ManagementTables and labels/lines showing trade levels and risk/reward. Use to manage trade risk compared to portfolio size.
Initial design optimised for tickers denominated against USD.
Multi-Session High/Low Trackertable that shows rth eth and full weekly range high and low with range difference from high and low
Table ATH and DayQuotes in the middle of a chartJust important things at a glance ..
AlltimeHigh and Daily High/Low
Volume Profile AnalysisThe Volume Profile Dashboard is a professional-grade analysis tool built for TradingView. It focuses on displaying a comprehensive volume profile breakdown within a dashboard format directly on the chart. The purpose of this tool is to help traders quickly assess buy versus sell volume dynamics, momentum, and sentiment in order to support informed trading decisions.
Instead of plotting simple bars, this indicator uses a detailed table and visual progress bar to summarize live and historical market activity. By condensing key metrics into a structured format, traders can analyse market behaviour without manually calculating or switching between multiple indicators.
________________________________________
How the Script Works
1. Data Gathering
The script uses lower-timeframe price and volume data to calculate buy volume, sell volume, and total traded volume for the current and previous candles.
2. Volume Allocation
Buy and sell volumes are estimated by looking at the candle’s range (high to low) and how the closing price aligns within that range. The closer the close is to the high, the stronger the buying pressure. The closer the close is to the low, the stronger the selling pressure.
3. Delta and Momentum
o Delta measures the difference between buy and sell volume.
o Volume momentum compares the current candle’s activity to the previous one, showing if interest is rising or fading.
4. Point of Control (POC)
An average of high, low, and close is calculated to give an approximate “point of control” level—an area of balance where buyers and sellers previously agreed on price.
5. Dashboard Visualization
All these calculations are displayed inside a clean dashboard table with separate rows for the current candle, previous candle, and a summary row. Icons, colors, and progress bars make it visually intuitive.
6. On-Chart Progress Indicator
A dynamic horizontal progress bar is plotted on the chart above price, showing the balance between buy and sell volume for the latest activity.
7. Alerts
Built-in alerts trigger when strong buying or selling pressure is detected or when there is a significant spike in total traded volume.
________________________________________
How This Tool Can Be Used
• Intraday Trading: Quickly gauge whether buyers or sellers are in control of the market at any moment.
• Swing Trading: Compare momentum shifts between candles to identify early trend reversals.
• Risk Management: Use delta and sentiment signals to confirm whether to hold or reduce exposure.
• Confirmation: Align the volume profile dashboard with other indicators (such as RSI, MACD, or trendlines) for stronger trading conviction.
________________________________________
Using Mixed Indicators for Decisions
This dashboard alone provides volume insights, but better decisions come when it is combined with other tools:
• Pairing it with an RSI can show whether heavy buying is happening in overbought conditions.
• Combining with a SuperTrend or moving averages can confirm if volume momentum aligns with the price trend.
• Overlaying support/resistance levels can identify whether strong buy/sell signals occur at critical levels.
Mixed indicators prevent relying on one signal alone, reducing false trades.
________________________________________
Importance of This Tool
• Clarity: Condenses complex volume data into a simple, visual format.
• Speed: Traders can react faster with pre-calculated buy/sell percentages.
• Precision: Highlights hidden imbalances that are not obvious from candles alone.
• Professional-grade dashboard: Offers an institutional-style view of market behavior directly within TradingView.
________________________________________
Parameters in the Dashboard Table
• Period: Shows whether the row is for the current or previous candle, along with trend arrows.
• Price Range: The high–low range of the candle.
• Total Volume: The sum of buy and sell activity.
• Buy Volume / Sell Volume: Separated distribution of transactions leaning bullish or bearish.
• Delta: The net difference between buy and sell volumes, highlighting pressure imbalance.
• Buy % / Sell %: The percentage contribution of each side to total volume.
• POC: An average reference level where market consensus was strongest.
• Progress: A graphical bar showing buy vs sell dominance.
• Signal: Simplified output like Strong Buy, Buy, Strong Sell, Sell, Neutral.
• Summary Row: Compares changes between the current and previous candles and gives overall market sentiment.
________________________________________
Stock Market Disclaimer
This tool is for educational and informational purposes only. It does not constitute financial advice, investment advice, or trading recommendations. The stock market and cryptocurrency markets involve high risk. Traders and investors should do their own research and consult licensed financial advisors before making investment decisions. Past performance is not indicative of future results.
________________________________________
Misuse Disclaimer
This script has been developed as per TradingView’s rules and is intended for responsible trading analysis only. Any misuse, redistribution, or modification outside of TradingView’s policies is discouraged. The author and platform are not responsible for financial losses, misinterpretation of signals, or misuse of the code.
________________________________________
Disclaimer
Training & Educational Only — This material and the indicator are provided for educational purposes only. Nothing here is investment advice or a solicitation to buy or sell financial instruments. Past simulated or historical performance does not predict future results. Always perform full back testing and risk management, and consider seeking advice from a qualified financial professional before trading with real capital.
________________________________________
Swing Oracle Stock// (\_/)
// ( •.•)
// (")_(")
📌 Swing Oracle Stock – Professional Cycle & Trend Detection Indicator
The Swing Oracle Stock is an advanced market analysis tool designed to highlight price cycles, trend shifts, and key trading zones with precision. It combines trendline dynamics, normalized oscillators, and multi-timeframe confirmation into a single comprehensive indicator.
🔑 Key Features
NDOS (Normalized Dynamic Oscillator System):
Measures price strength relative to recent highs and lows to detect overbought, neutral, and oversold zones.
Dynamic Trendline (EMA8 or SMA231):
Flexible source selection for adapting to different trading styles (scalping vs. swing).
Multi-Timeframe H1 Confirmation:
Adds higher-timeframe validation to improve signal reliability.
Automated Buy & Sell Signals:
Triggered only on significant crossovers above/below defined levels.
Weekly Cycles (7-day M5 projection):
Tracks recurring time-based market cycles to anticipate reversal points.
Intuitive Visualization:
Colored zones (high, low, neutral) for quick market context.
Optional background and candlestick coloring for better clarity.
Multi-Timeframe Cross Table:
Automatically compares SMA50 vs. EMA200 across multiple timeframes (1m → 4h), showing clear status:
⭐️⬆️ UP = bullish trend confirmation
💀⬇️ Drop = bearish trend confirmation
📊 Built-in Statistical Tools
Normalized difference between short and long EMA.
Projected normalized mean levels plotted directly on the main chart.
Dynamic analysis of price distance from SMA50 to capture market “waves.”
🎯 Use Cases
Spot trend reversals with multi-timeframe confirmation.
Identify powerful breakout and breakdown zones.
Time entries and exits based on trend + cycle confluence.
Enhance market timing for swing trades, scalps, or long-term positions.
⚡ Swing Oracle Stock brings together cycle detection, oscillator normalization, and multi-timeframe confirmation into one streamlined indicator for traders who want a professional edge.
Engulfing Candles Tarama// This Pine Scriptâ„¢ code is subject to the terms of the Mozilla Public License 2.0 at mozilla.org
// © dipavcisi0007
//@version=5
indicator('Engulfing Candles Tarama', overlay=true)
longer = ta.sma(close, 50)
short = ta.sma(close, 20)
length1 = input(14)
price = close
length = input.int(20, minval=1)
ad = close == high and close == low or high == low ? 0 : (close - open) / (high - low) * volume
//ad = close==high and close==low or high==low ? 0 : ((2*close-low-high)/(high-low))*volume
mf = math.sum(ad, length) / math.sum(volume, length)
crsis = mf
openBarCurrent1 = open
closeBarCurrent1 = close
highBarCurrent1 = high
lowBarCurrent1 = low
volumeBarCurrent1 = volume
topvolumeBarCurrent1 = math.sum(volume , 50) / 50
BarOran1 = (closeBarCurrent1 - openBarCurrent1) / (highBarCurrent1 - lowBarCurrent1)
//BarOran1=(2*closeBarCurrent1-lowBarCurrent1-highBarCurrent1)/(highBarCurrent1-lowBarCurrent1)
openBarCurrent2 = open
closeBarCurrent2 = close
highBarCurrent2 = high
lowBarCurrent2 = low
volumeBarCurrent2 = volume
topvolumeBarCurrent2 = math.sum(volume , 50) / 50
BarOran2 = (closeBarCurrent2 - openBarCurrent2) / (highBarCurrent2 - lowBarCurrent2)
//BarOran2=(2*closeBarCurrent2-lowBarCurrent2-highBarCurrent2)/(highBarCurrent2-lowBarCurrent2)
openBarCurrent3 = open
closeBarCurrent3 = close
highBarCurrent3 = high
lowBarCurrent3 = low
volumeBarCurrent3 = volume
topvolumeBarCurrent3 = math.sum(volume , 50) / 50
BarOran3 = (closeBarCurrent3 - openBarCurrent3) / (highBarCurrent3 - lowBarCurrent3)
//BarOran3=(2*closeBarCurrent3-lowBarCurrent3-highBarCurrent3)/(highBarCurrent3-lowBarCurrent3)
cmi = 0.15
oran = 0.90
katsayi = 1.05
stoporan = 1
length2 = input(14)
price1 = close
vrsi = ta.rsi(price1, length2)
//If current bar open is less than equal to the previous bar close AND current bar open is less than previous bar open AND current bar close is greater than previous bar open THEN True
bullishEngulfing1 = BarOran1 > oran and BarOran1 * volumeBarCurrent1 > topvolumeBarCurrent1 * katsayi and crsis > cmi and close > highBarCurrent1
//If current bar open is greater than equal to previous bar close AND current bar open is greater than previous bar open AND current bar close is less than previous bar open THEN True
bullishEngulfing2 = BarOran2 > oran and BarOran2 * volumeBarCurrent2 > topvolumeBarCurrent2 * katsayi and crsis > cmi and close > highBarCurrent2
//If current bar open is greater than equal to previous bar close AND current bar open is greater than previous bar open AND current bar close is less than previous bar open THEN True
bullishEngulfing3 = BarOran3 > oran and BarOran3 * volumeBarCurrent3 > topvolumeBarCurrent3 * katsayi and crsis > cmi and close > highBarCurrent3
var K1 = 0.0
res = input.timeframe(title='Time Frame', defval='D')
if bullishEngulfing1
K1 := lowBarCurrent1
else if bullishEngulfing2
K1 := lowBarCurrent2
else if bullishEngulfing3
K1 := lowBarCurrent3
plot(K1, linewidth=2, color=color.new(color.purple, 0), title='TSL')
//bullishEngulfing/bearishEngulfing return a value of 1 or 0; if 1 then plot on chart, if 0 then don't plot
plotshape(bullishEngulfing1 or bullishEngulfing2 or bullishEngulfing3, style=shape.triangleup, location=location.belowbar, color=color.new(#43A047, 0), size=size.tiny)
////////////////////////
grupSec = input.string(defval='1', options= , group='Taraması yapılacak 40\'arlı gruplardan birini seçin', title='Grup seç')
per = input.timeframe(defval='', title='PERİYOT',group = "Tarama yapmak istediğiniz periyotu seçin")
func() =>
cond = bullishEngulfing1 or bullishEngulfing2 or bullishEngulfing3
//GRUP VE TARANACAK HİSSE SAYISINI AYNI ÅEKİLDE DİLEDİÄİNİZ GİBİ ARTIRABİLİRSİNİZ.
a01 = grupSec == '1' ? 'BIST:A1CAP' : grupSec == '2' ? 'BIST:ANSGR' : grupSec == '3' ? 'BIST:BEYAZ' : grupSec == '4' ? 'BIST:CEMZY' : grupSec == '5' ? 'BIST:DURKN' : grupSec == '6' ? 'BIST:EUYO' : grupSec == '7' ? 'BIST:HALKB' : grupSec == '8' ? 'BIST:ISGYO' : grupSec == '9' ? 'BIST:KOPOL' : grupSec == '10' ? 'BIST:MARKA' : grupSec == '11' ? 'BIST:ONCSM' : grupSec == '12' ? 'BIST:POLTK' : grupSec == '13' ? 'BIST:SISE' : grupSec == '14' ? 'BIST:TOASO' : grupSec == '15' ? 'BIST:YBTAS' : na
a02 = grupSec == '1' ? 'BIST:ACSEL' : grupSec == '2' ? 'BIST:ARASE' : grupSec == '3' ? 'BIST:BFREN' : grupSec == '4' ? 'BIST:CEOEM' : grupSec == '5' ? 'BIST:DYOBY' : grupSec == '6' ? 'BIST:EYGYO' : grupSec == '7' ? 'BIST:HATEK' : grupSec == '8' ? 'BIST:ISKPL' : grupSec == '9' ? 'BIST:KORDS' : grupSec == '10' ? 'BIST:MARTI' : grupSec == '11' ? 'BIST:ONRYT' : grupSec == '12' ? 'BIST:PRDGS' : grupSec == '13' ? 'BIST:SKBNK' : grupSec == '14' ? 'BIST:TRCAS' : grupSec == '15' ? 'BIST:YEOTK' : na
a03 = grupSec == '1' ? 'BIST:ADEL' : grupSec == '2' ? 'BIST:ARCLK' : grupSec == '3' ? 'BIST:BIENY' : grupSec == '4' ? 'BIST:CIMSA' : grupSec == '5' ? 'BIST:DZGYO' : grupSec == '6' ? 'BIST:FADE' : grupSec == '7' ? 'BIST:HATSN' : grupSec == '8' ? 'BIST:ISKUR' : grupSec == '9' ? 'BIST:KOTON' : grupSec == '10' ? 'BIST:MAVI' : grupSec == '11' ? 'BIST:ORCAY' : grupSec == '12' ? 'BIST:PRKAB' : grupSec == '13' ? 'BIST:SKTAS' : grupSec == '14' ? 'BIST:TRGYO' : grupSec == '15' ? 'BIST:YESIL' : na
a04 = grupSec == '1' ? 'BIST:ADESE' : grupSec == '2' ? 'BIST:ARDYZ' : grupSec == '3' ? 'BIST:BIGCH' : grupSec == '4' ? 'BIST:CLEBI' : grupSec == '5' ? 'BIST:EBEBK' : grupSec == '6' ? 'BIST:FENER' : grupSec == '7' ? 'BIST:HDFGS' : grupSec == '8' ? 'BIST:ISMEN' : grupSec == '9' ? 'BIST:KOZAA' : grupSec == '10' ? 'BIST:MEDTR' : grupSec == '11' ? 'BIST:ORGE' : grupSec == '12' ? 'BIST:PRKME' : grupSec == '13' ? 'BIST:SKYLP' : grupSec == '14' ? 'BIST:TRILC' : grupSec == '15' ? 'BIST:YGGYO' : na
a05 = grupSec == '1' ? 'BIST:ADGYO' : grupSec == '2' ? 'BIST:ARENA' : grupSec == '3' ? 'BIST:BIMAS' : grupSec == '4' ? 'BIST:CMBTN' : grupSec == '5' ? 'BIST:ECILC' : grupSec == '6' ? 'BIST:FLAP' : grupSec == '7' ? 'BIST:HEDEF' : grupSec == '8' ? 'BIST:ISSEN' : grupSec == '9' ? 'BIST:KOZAL' : grupSec == '10' ? 'BIST:MEGAP' : grupSec == '11' ? 'BIST:ORMA' : grupSec == '12' ? 'BIST:PRZMA' : grupSec == '13' ? 'BIST:SKYMD' : grupSec == '14' ? 'BIST:TSGYO' : grupSec == '15' ? 'BIST:YGYO' : na
a06 = grupSec == '1' ? 'BIST:AEFES' : grupSec == '2' ? 'BIST:ARSAN' : grupSec == '3' ? 'BIST:BINBN' : grupSec == '4' ? 'BIST:CMENT' : grupSec == '5' ? 'BIST:ECZYT' : grupSec == '6' ? 'BIST:FMIZP' : grupSec == '7' ? 'BIST:HEKTS' : grupSec == '8' ? 'BIST:ISYAT' : grupSec == '9' ? 'BIST:KRDMA' : grupSec == '10' ? 'BIST:MEGMT' : grupSec == '11' ? 'BIST:OSMEN' : grupSec == '12' ? 'BIST:PSDTC' : grupSec == '13' ? 'BIST:SMART' : grupSec == '14' ? 'BIST:TSKB' : grupSec == '15' ? 'BIST:YIGIT' : na
a07 = grupSec == '1' ? 'BIST:AFYON' : grupSec == '2' ? 'BIST:ARTMS' : grupSec == '3' ? 'BIST:BINHO' : grupSec == '4' ? 'BIST:CONSE' : grupSec == '5' ? 'BIST:EDATA' : grupSec == '6' ? 'BIST:FONET' : grupSec == '7' ? 'BIST:HKTM' : grupSec == '8' ? 'BIST:IZENR' : grupSec == '9' ? 'BIST:KRDMB' : grupSec == '10' ? 'BIST:MEKAG' : grupSec == '11' ? 'BIST:OSTIM' : grupSec == '12' ? 'BIST:PSGYO' : grupSec == '13' ? 'BIST:SMRTG' : grupSec == '14' ? 'BIST:TSPOR' : grupSec == '15' ? 'BIST:YKBNK' : na
a08 = grupSec == '1' ? 'BIST:AGESA' : grupSec == '2' ? 'BIST:ARZUM' : grupSec == '3' ? 'BIST:BIOEN' : grupSec == '4' ? 'BIST:COSMO' : grupSec == '5' ? 'BIST:EDIP' : grupSec == '6' ? 'BIST:FORMT' : grupSec == '7' ? 'BIST:HLGYO' : grupSec == '8' ? 'BIST:IZFAS' : grupSec == '9' ? 'BIST:KRDMD' : grupSec == '10' ? 'BIST:MEPET' : grupSec == '11' ? 'BIST:OTKAR' : grupSec == '12' ? 'BIST:QNBFK' : grupSec == '13' ? 'BIST:SNGYO' : grupSec == '14' ? 'BIST:TTKOM' : grupSec == '15' ? 'BIST:YKSLN' : na
a09 = grupSec == '1' ? 'BIST:AGHOL' : grupSec == '2' ? 'BIST:ASELS' : grupSec == '3' ? 'BIST:BIZIM' : grupSec == '4' ? 'BIST:CRDFA' : grupSec == '5' ? 'BIST:EFORC' : grupSec == '6' ? 'BIST:FORTE' : grupSec == '7' ? 'BIST:HOROZ' : grupSec == '8' ? 'BIST:IZINV' : grupSec == '9' ? 'BIST:KRGYO' : grupSec == '10' ? 'BIST:MERCN' : grupSec == '11' ? 'BIST:OTTO' : grupSec == '12' ? 'BIST:QNBTR' : grupSec == '13' ? 'BIST:SNICA' : grupSec == '14' ? 'BIST:TTRAK' : grupSec == '15' ? 'BIST:YONGA' : na
a10 = grupSec == '1' ? 'BIST:AGROT' : grupSec == '2' ? 'BIST:ASGYO' : grupSec == '3' ? 'BIST:BJKAS' : grupSec == '4' ? 'BIST:CRFSA' : grupSec == '5' ? 'BIST:EGEEN' : grupSec == '6' ? 'BIST:FRIGO' : grupSec == '7' ? 'BIST:HRKET' : grupSec == '8' ? 'BIST:IZMDC' : grupSec == '9' ? 'BIST:KRONT' : grupSec == '10' ? 'BIST:MERIT' : grupSec == '11' ? 'BIST:OYAKC' : grupSec == '12' ? 'BIST:QUAGR' : grupSec == '13' ? 'BIST:SNKRN' : grupSec == '14' ? 'BIST:TUCLK' : grupSec == '15' ? 'BIST:YUNSA' : na
a11 = grupSec == '1' ? 'BIST:AGYO' : grupSec == '2' ? 'BIST:ASTOR' : grupSec == '3' ? 'BIST:BLCYT' : grupSec == '4' ? 'BIST:CUSAN' : grupSec == '5' ? 'BIST:EGEPO' : grupSec == '6' ? 'BIST:FROTO' : grupSec == '7' ? 'BIST:HTTBT' : grupSec == '8' ? 'BIST:JANTS' : grupSec == '9' ? 'BIST:KRPLS' : grupSec == '10' ? 'BIST:MERKO' : grupSec == '11' ? 'BIST:OYAYO' : grupSec == '12' ? 'BIST:RALYH' : grupSec == '13' ? 'BIST:SNPAM' : grupSec == '14' ? 'BIST:TUKAS' : grupSec == '15' ? 'BIST:YYAPI' : na
a12 = grupSec == '1' ? 'BIST:AHGAZ' : grupSec == '2' ? 'BIST:ASUZU' : grupSec == '3' ? 'BIST:BMSCH' : grupSec == '4' ? 'BIST:CVKMD' : grupSec == '5' ? 'BIST:EGGUB' : grupSec == '6' ? 'BIST:FZLGY' : grupSec == '7' ? 'BIST:HUBVC' : grupSec == '8' ? 'BIST:KAPLM' : grupSec == '9' ? 'BIST:KRSTL' : grupSec == '10' ? 'BIST:METRO' : grupSec == '11' ? 'BIST:OYLUM' : grupSec == '12' ? 'BIST:RAYSG' : grupSec == '13' ? 'BIST:SODSN' : grupSec == '14' ? 'BIST:TUPRS' : grupSec == '15' ? 'BIST:YYLGD' : na
a13 = grupSec == '1' ? 'BIST:AHSGY' : grupSec == '2' ? 'BIST:ATAGY' : grupSec == '3' ? 'BIST:BMSTL' : grupSec == '4' ? 'BIST:CWENE' : grupSec == '5' ? 'BIST:EGPRO' : grupSec == '6' ? 'BIST:GARAN' : grupSec == '7' ? 'BIST:HUNER' : grupSec == '8' ? 'BIST:KAREL' : grupSec == '9' ? 'BIST:KRTEK' : grupSec == '10' ? 'BIST:METUR' : grupSec == '11' ? 'BIST:OYYAT' : grupSec == '12' ? 'BIST:REEDR' : grupSec == '13' ? 'BIST:SOKE' : grupSec == '14' ? 'BIST:TUREX' : grupSec == '15' ? 'BIST:ZEDUR' : na
a14 = grupSec == '1' ? 'BIST:AKBNK' : grupSec == '2' ? 'BIST:ATAKP' : grupSec == '3' ? 'BIST:BNTAS' : grupSec == '4' ? 'BIST:DAGHL' : grupSec == '5' ? 'BIST:EGSER' : grupSec == '6' ? 'BIST:GARFA' : grupSec == '7' ? 'BIST:HURGZ' : grupSec == '8' ? 'BIST:KARSN' : grupSec == '9' ? 'BIST:KRVGD' : grupSec == '10' ? 'BIST:MGROS' : grupSec == '11' ? 'BIST:OZATD' : grupSec == '12' ? 'BIST:RGYAS' : grupSec == '13' ? 'BIST:SOKM' : grupSec == '14' ? 'BIST:TURGG' : grupSec == '15' ? 'BIST:ZOREN' : na
a15 = grupSec == '1' ? 'BIST:AKCNS' : grupSec == '2' ? 'BIST:ATATP' : grupSec == '3' ? 'BIST:BOBET' : grupSec == '4' ? 'BIST:DAGI' : grupSec == '5' ? 'BIST:EKGYO' : grupSec == '6' ? 'BIST:GEDIK' : grupSec == '7' ? 'BIST:ICBCT' : grupSec == '8' ? 'BIST:KARTN' : grupSec == '9' ? 'BIST:KSTUR' : grupSec == '10' ? 'BIST:MHRGY' : grupSec == '11' ? 'BIST:OZGYO' : grupSec == '12' ? 'BIST:RNPOL' : grupSec == '13' ? 'BIST:SONME' : grupSec == '14' ? 'BIST:TURSG' : grupSec == '15' ? 'BIST:ZRGYO' : na
a16 = grupSec == '1' ? 'BIST:AKENR' : grupSec == '2' ? 'BIST:ATEKS' : grupSec == '3' ? 'BIST:BORLS' : grupSec == '4' ? 'BIST:DAPGM' : grupSec == '5' ? 'BIST:EKIZ' : grupSec == '6' ? 'BIST:GEDZA' : grupSec == '7' ? 'BIST:ICUGS' : grupSec == '8' ? 'BIST:KARYE' : grupSec == '9' ? 'BIST:KTLEV' : grupSec == '10' ? 'BIST:MIATK' : grupSec == '11' ? 'BIST:OZKGY' : grupSec == '12' ? 'BIST:RODRG' : grupSec == '13' ? 'BIST:SRVGY' : grupSec == '14' ? 'BIST:UFUK' : grupSec == '15' ? 'BIST:AKFIS' :na
a17 = grupSec == '1' ? 'BIST:AKFGY' : grupSec == '2' ? 'BIST:ATLAS' : grupSec == '3' ? 'BIST:BORSK' : grupSec == '4' ? 'BIST:DARDL' : grupSec == '5' ? 'BIST:EKOS' : grupSec == '6' ? 'BIST:GENIL' : grupSec == '7' ? 'BIST:IDGYO' : grupSec == '8' ? 'BIST:KATMR' : grupSec == '9' ? 'BIST:KTSKR' : grupSec == '10' ? 'BIST:MMCAS' : grupSec == '11' ? 'BIST:OZRDN' : grupSec == '12' ? 'BIST:ROYAL' : grupSec == '13' ? 'BIST:SUMAS' : grupSec == '14' ? 'BIST:ULAS' : grupSec == '15' ? 'BIST:ARMGD': na
a18 = grupSec == '1' ? 'BIST:AKFYE' : grupSec == '2' ? 'BIST:ATSYH' : grupSec == '3' ? 'BIST:BOSSA' : grupSec == '4' ? 'BIST:DCTTR' : grupSec == '5' ? 'BIST:EKSUN' : grupSec == '6' ? 'BIST:GENTS' : grupSec == '7' ? 'BIST:IEYHO' : grupSec == '8' ? 'BIST:KAYSE' : grupSec == '9' ? 'BIST:KUTPO' : grupSec == '10' ? 'BIST:MNDRS' : grupSec == '11' ? 'BIST:OZSUB' : grupSec == '12' ? 'BIST:RTALB' : grupSec == '13' ? 'BIST:SUNTK' : grupSec == '14' ? 'BIST:ULKER' : grupSec == '15' ? 'BIST:BALSU': na
a19 = grupSec == '1' ? 'BIST:AKGRT' : grupSec == '2' ? 'BIST:AVGYO' : grupSec == '3' ? 'BIST:BRISA' : grupSec == '4' ? 'BIST:DENGE' : grupSec == '5' ? 'BIST:ELITE' : grupSec == '6' ? 'BIST:GEREL' : grupSec == '7' ? 'BIST:IHAAS' : grupSec == '8' ? 'BIST:KBORU' : grupSec == '9' ? 'BIST:KUVVA' : grupSec == '10' ? 'BIST:MNDTR' : grupSec == '11' ? 'BIST:OZYSR' : grupSec == '12' ? 'BIST:RUBNS' : grupSec == '13' ? 'BIST:SURGY' : grupSec == '14' ? 'BIST:ULUFA' : grupSec == '15' ? 'BIST:BESLR':na
a20 = grupSec == '1' ? 'BIST:AKMGY' : grupSec == '2' ? 'BIST:AVHOL' : grupSec == '3' ? 'BIST:BRKO' : grupSec == '4' ? 'BIST:DERHL' : grupSec == '5' ? 'BIST:EMKEL' : grupSec == '6' ? 'BIST:GESAN' : grupSec == '7' ? 'BIST:IHEVA' : grupSec == '8' ? 'BIST:KCAER' : grupSec == '9' ? 'BIST:KUYAS' : grupSec == '10' ? 'BIST:MOBTL' : grupSec == '11' ? 'BIST:PAGYO' : grupSec == '12' ? 'BIST:RYGYO' : grupSec == '13' ? 'BIST:SUWEN' : grupSec == '14' ? 'BIST:ULUSE' : grupSec == '15' ? 'BIST:DSTKF': na
a21 = grupSec == '1' ? 'BIST:AKSA' : grupSec == '2' ? 'BIST:AVOD' : grupSec == '3' ? 'BIST:BRKSN' : grupSec == '4' ? 'BIST:DERIM' : grupSec == '5' ? 'BIST:EMNIS' : grupSec == '6' ? 'BIST:GIPTA' : grupSec == '7' ? 'BIST:IHGZT' : grupSec == '8' ? 'BIST:KCHOL' : grupSec == '9' ? 'BIST:KZBGY' : grupSec == '10' ? 'BIST:MOGAN' : grupSec == '11' ? 'BIST:PAMEL' : grupSec == '12' ? 'BIST:RYSAS' : grupSec == '13' ? 'BIST:TABGD' : grupSec == '14' ? 'BIST:ULUUN' : grupSec == '15' ? 'BIST:GLRMK': na
a22 = grupSec == '1' ? 'BIST:AKSEN' : grupSec == '2' ? 'BIST:AVPGY' : grupSec == '3' ? 'BIST:BRKVY' : grupSec == '4' ? 'BIST:DESA' : grupSec == '5' ? 'BIST:ENERY' : grupSec == '6' ? 'BIST:GLBMD' : grupSec == '7' ? 'BIST:IHLAS' : grupSec == '8' ? 'BIST:KENT' : grupSec == '9' ? 'BIST:KZGYO' : grupSec == '10' ? 'BIST:MPARK' : grupSec == '11' ? 'BIST:PAPIL' : grupSec == '12' ? 'BIST:SAFKR' : grupSec == '13' ? 'BIST:TARKM' : grupSec == '14' ? 'BIST:UMPAS' : grupSec == '15' ? 'BIST:KLYPV': na
a23 = grupSec == '1' ? 'BIST:AKSGY' : grupSec == '2' ? 'BIST:AVTUR' : grupSec == '3' ? 'BIST:BRLSM' : grupSec == '4' ? 'BIST:DESPC' : grupSec == '5' ? 'BIST:ENJSA' : grupSec == '6' ? 'BIST:GLCVY' : grupSec == '7' ? 'BIST:IHLGM' : grupSec == '8' ? 'BIST:KERVN' : grupSec == '9' ? 'BIST:LIDER' : grupSec == '10' ? 'BIST:MRGYO' : grupSec == '11' ? 'BIST:PARSN' : grupSec == '12' ? 'BIST:SAHOL' : grupSec == '13' ? 'BIST:TATEN' : grupSec == '14' ? 'BIST:UNLU' :grupSec == '15' ? 'BIST:MOPAS': na
a24 = grupSec == '1' ? 'BIST:AKSUE' : grupSec == '2' ? 'BIST:AYCES' : grupSec == '3' ? 'BIST:BRMEN' : grupSec == '4' ? 'BIST:DEVA' : grupSec == '5' ? 'BIST:ENKAI' : grupSec == '6' ? 'BIST:GLRYH' : grupSec == '7' ? 'BIST:IHYAY' : grupSec == '8' ? 'BIST:LIDFA' : grupSec == '10' ? 'BIST:MRSHL' : grupSec == '11' ? 'BIST:PASEU' : grupSec == '12' ? 'BIST:SAMAT' : grupSec == '13' ? 'BIST:TATGD' : grupSec == '14' ? 'BIST:USAK' : grupSec == '15' ? 'BIST:A1YEN': na
a25 = grupSec == '1' ? 'BIST:AKYHO' : grupSec == '2' ? 'BIST:AYDEM' : grupSec == '3' ? 'BIST:BRSAN' : grupSec == '4' ? 'BIST:DGATE' : grupSec == '5' ? 'BIST:ENSRI' : grupSec == '6' ? 'BIST:GLYHO' : grupSec == '7' ? 'BIST:IMASM' : grupSec == '8' ? 'BIST:KFEIN' : grupSec == '9' ? 'BIST:LILAK' : grupSec == '10' ? 'BIST:MSGYO' : grupSec == '11' ? 'BIST:PATEK' : grupSec == '12' ? 'BIST:SANEL' : grupSec == '13' ? 'BIST:TAVHL' : grupSec == '14' ? 'BIST:VAKBN' : grupSec == '15' ? 'BIST:BIGEN': na
a26 = grupSec == '1' ? 'BIST:ALARK' : grupSec == '2' ? 'BIST:AYEN' : grupSec == '3' ? 'BIST:BRYAT' : grupSec == '4' ? 'BIST:DGGYO' : grupSec == '5' ? 'BIST:ENTRA' : grupSec == '6' ? 'BIST:GMTAS' : grupSec == '7' ? 'BIST:INDES' : grupSec == '8' ? 'BIST:KGYO' : grupSec == '9' ? 'BIST:LINK' : grupSec == '10' ? 'BIST:MTRKS' : grupSec == '11' ? 'BIST:PCILT' : grupSec == '12' ? 'BIST:SANFM' : grupSec == '13' ? 'BIST:TBORG' : grupSec == '14' ? 'BIST:VAKFN' : grupSec == '15' ? 'BIST:BULGS': na
a27 = grupSec == '1' ? 'BIST:ALBRK' : grupSec == '2' ? 'BIST:AYES' : grupSec == '3' ? 'BIST:BSOKE' : grupSec == '4' ? 'BIST:DGNMO' : grupSec == '5' ? 'BIST:EPLAS' : grupSec == '6' ? 'BIST:GOKNR' : grupSec == '7' ? 'BIST:INFO' : grupSec == '8' ? 'BIST:KIMMR' : grupSec == '9' ? 'BIST:LKMNH' : grupSec == '10' ? 'BIST:MTRYO' : grupSec == '11' ? 'BIST:PEHOL' : grupSec == '12' ? 'BIST:SANKO' : grupSec == '13' ? 'BIST:TCELL' : grupSec == '14' ? 'BIST:VAKKO' : grupSec == '15' ? 'BIST:CGCAM': na
a28 = grupSec == '1' ? 'BIST:ALCAR' : grupSec == '2' ? 'BIST:AYGAZ' : grupSec == '3' ? 'BIST:BTCIM' : grupSec == '4' ? 'BIST:DIRIT' : grupSec == '5' ? 'BIST:ERBOS' : grupSec == '6' ? 'BIST:GOLTS' : grupSec == '7' ? 'BIST:INGRM' : grupSec == '8' ? 'BIST:KLGYO' : grupSec == '9' ? 'BIST:LMKDC' : grupSec == '10' ? 'BIST:MZHLD' : grupSec == '11' ? 'BIST:PEKGY' : grupSec == '12' ? 'BIST:SARKY' : grupSec == '13' ? 'BIST:TCKRC' : grupSec == '14' ? 'BIST:VANGD' : grupSec == '15' ? 'BIST:EGEGY': na
a29 = grupSec == '1' ? 'BIST:ALCTL' : grupSec == '2' ? 'BIST:AZTEK' : grupSec == '3' ? 'BIST:BUCIM' : grupSec == '4' ? 'BIST:DITAS' : grupSec == '5' ? 'BIST:ERCB' : grupSec == '6' ? 'BIST:GOODY' : grupSec == '7' ? 'BIST:INTEK' : grupSec == '8' ? 'BIST:KLKIM' : grupSec == '9' ? 'BIST:LOGO' : grupSec == '10' ? 'BIST:NATEN' : grupSec == '11' ? 'BIST:PENGD' : grupSec == '12' ? 'BIST:SASA' : grupSec == '13' ? 'BIST:TDGYO' : grupSec == '14' ? 'BIST:VBTYZ' : grupSec == '15' ? 'BIST:ENDAE':na
a30 = grupSec == '1' ? 'BIST:ALFAS' : grupSec == '2' ? 'BIST:BAGFS' : grupSec == '3' ? 'BIST:BURCE' : grupSec == '4' ? 'BIST:DMRGD' : grupSec == '5' ? 'BIST:EREGL' : grupSec == '6' ? 'BIST:GOZDE' : grupSec == '7' ? 'BIST:INTEM' : grupSec == '8' ? 'BIST:KLMSN' : grupSec == '9' ? 'BIST:LRSHO' : grupSec == '10' ? 'BIST:NETAS' : grupSec == '11' ? 'BIST:PENTA' : grupSec == '12' ? 'BIST:SAYAS' : grupSec == '13' ? 'BIST:TEKTU' : grupSec == '14' ? 'BIST:VERTU' : grupSec == '15' ? 'BIST:RUZYE': na
a31 = grupSec == '1' ? 'BIST:ALGYO' : grupSec == '2' ? 'BIST:BAHKM' : grupSec == '3' ? 'BIST:BURVA' : grupSec == '4' ? 'BIST:DMSAS' : grupSec == '5' ? 'BIST:ERSU' : grupSec == '6' ? 'BIST:GRNYO' : grupSec == '7' ? 'BIST:INVEO' : grupSec == '8' ? 'BIST:KLNMA' : grupSec == '9' ? 'BIST:LUKSK' : grupSec == '10' ? 'BIST:NIBAS' : grupSec == '11' ? 'BIST:PETKM' : grupSec == '12' ? 'BIST:SDTTR' : grupSec == '13' ? 'BIST:TERA' : grupSec == '14' ? 'BIST:VERUS' : grupSec == '15' ? 'BIST:SERNT': na
a32 = grupSec == '1' ? 'BIST:ALKA' : grupSec == '2' ? 'BIST:BAKAB' : grupSec == '3' ? 'BIST:BVSAN' : grupSec == '4' ? 'BIST:DNISI' : grupSec == '5' ? 'BIST:ESCAR' : grupSec == '6' ? 'BIST:GRSEL' : grupSec == '7' ? 'BIST:INVES' : grupSec == '8' ? 'BIST:KLRHO' : grupSec == '9' ? 'BIST:LYDHO' : grupSec == '10' ? 'BIST:NTGAZ' : grupSec == '11' ? 'BIST:PETUN' : grupSec == '12' ? 'BIST:SEGMN' : grupSec == '13' ? 'BIST:TEZOL' : grupSec == '14' ? 'BIST:VESBE' : grupSec == '15' ? 'BIST:SMRVA':na
a33 = grupSec == '1' ? 'BIST:ALKIM' : grupSec == '2' ? 'BIST:BALAT' : grupSec == '3' ? 'BIST:BYDNR' : grupSec == '4' ? 'BIST:DOAS' : grupSec == '5' ? 'BIST:ESCOM' : grupSec == '6' ? 'BIST:GRTHO' : grupSec == '7' ? 'BIST:IPEKE' : grupSec == '8' ? 'BIST:KLSER' : grupSec == '9' ? 'BIST:LYDYE' : grupSec == '10' ? 'BIST:NTHOL' : grupSec == '11' ? 'BIST:PGSUS' : grupSec == '12' ? 'BIST:SEGYO' : grupSec == '13' ? 'BIST:TGSAS' : grupSec == '14' ? 'BIST:VESTL' : grupSec == '15' ? 'BIST:VSNMD':na
a34 = grupSec == '1' ? 'BIST:ALKLC' : grupSec == '2' ? 'BIST:BANVT' : grupSec == '3' ? 'BIST:CANTE' : grupSec == '4' ? 'BIST:DOBUR' : grupSec == '5' ? 'BIST:ESEN' : grupSec == '6' ? 'BIST:GSDDE' : grupSec == '7' ? 'BIST:ISATR' : grupSec == '8' ? 'BIST:KLSYN' : grupSec == '9' ? 'BIST:MAALT' : grupSec == '10' ? 'BIST:NUGYO' : grupSec == '11' ? 'BIST:PINSU' : grupSec == '12' ? 'BIST:SEKFK' : grupSec == '13' ? 'BIST:THYAO' : grupSec == '14' ? 'BIST:VKFYO' : na
a35 = grupSec == '1' ? 'BIST:ALMAD' : grupSec == '2' ? 'BIST:BARMA' : grupSec == '3' ? 'BIST:CASA' : grupSec == '4' ? 'BIST:DOCO' : grupSec == '5' ? 'BIST:ETILR' : grupSec == '6' ? 'BIST:GSDHO' : grupSec == '7' ? 'BIST:ISBIR' : grupSec == '8' ? 'BIST:KMPUR' : grupSec == '9' ? 'BIST:MACKO' : grupSec == '10' ? 'BIST:NUHCM' : grupSec == '11' ? 'BIST:PKART' : grupSec == '12' ? 'BIST:SEKUR' : grupSec == '13' ? 'BIST:TKFEN' : grupSec == '14' ? 'BIST:VKGYO' : na
a36 = grupSec == '1' ? 'BIST:ALTNY' : grupSec == '2' ? 'BIST:BASCM' : grupSec == '3' ? 'BIST:CATES' : grupSec == '4' ? 'BIST:DOFER' : grupSec == '5' ? 'BIST:ETYAT' : grupSec == '6' ? 'BIST:GSRAY' : grupSec == '7' ? 'BIST:ISBTR' : grupSec == '8' ? 'BIST:KNFRT' : grupSec == '9' ? 'BIST:MAGEN' : grupSec == '10' ? 'BIST:OBAMS' : grupSec == '11' ? 'BIST:PKENT' : grupSec == '12' ? 'BIST:SELEC' : grupSec == '13' ? 'BIST:TKNSA' : grupSec == '14' ? 'BIST:VKING' : na
a37 = grupSec == '1' ? 'BIST:ALVES' : grupSec == '2' ? 'BIST:BASGZ' : grupSec == '3' ? 'BIST:CCOLA' : grupSec == '4' ? 'BIST:DOGUB' : grupSec == '5' ? 'BIST:EUHOL' : grupSec == '6' ? 'BIST:GUBRF' : grupSec == '7' ? 'BIST:ISCTR' : grupSec == '8' ? 'BIST:KOCMT' : grupSec == '9' ? 'BIST:MAKIM' : grupSec == '10' ? 'BIST:OBASE' : grupSec == '11' ? 'BIST:PLTUR' : grupSec == '12' ? 'BIST:SELGD' : grupSec == '13' ? 'BIST:TLMAN' : grupSec == '14' ? 'BIST:VRGYO' : na
a38 = grupSec == '1' ? 'BIST:ANELE' : grupSec == '2' ? 'BIST:BAYRK' : grupSec == '3' ? 'BIST:CELHA' : grupSec == '4' ? 'BIST:DOHOL' : grupSec == '5' ? 'BIST:EUKYO' : grupSec == '6' ? 'BIST:GUNDG' : grupSec == '7' ? 'BIST:ISDMR' : grupSec == '8' ? 'BIST:KONKA' : grupSec == '9' ? 'BIST:MAKTK' : grupSec == '10' ? 'BIST:ODAS' : grupSec == '11' ? 'BIST:PNLSN' : grupSec == '12' ? 'BIST:SELVA' : grupSec == '13' ? 'BIST:TMPOL' : grupSec == '14' ? 'BIST:YAPRK' : na
a39 = grupSec == '1' ? 'BIST:ANGEN' : grupSec == '2' ? 'BIST:BEGYO' : grupSec == '3' ? 'BIST:CEMAS' : grupSec == '4' ? 'BIST:DOKTA' : grupSec == '5' ? 'BIST:EUPWR' : grupSec == '6' ? 'BIST:GWIND' : grupSec == '7' ? 'BIST:ISFIN' : grupSec == '8' ? 'BIST:KONTR' : grupSec == '9' ? 'BIST:MANAS' : grupSec == '10' ? 'BIST:ODINE' : grupSec == '11' ? 'BIST:PNSUT' : grupSec == '12' ? 'BIST:SEYKM' : grupSec == '13' ? 'BIST:TMSN' : grupSec == '14' ? 'BIST:YATAS' : na
a40 = grupSec == '1' ? 'BIST:ANHYT' : grupSec == '2' ? 'BIST:BERA' : grupSec == '3' ? 'BIST:CEMTS' : grupSec == '4' ? 'BIST:DURDO' : grupSec == '5' ? 'BIST:EUREN' : grupSec == '6' ? 'BIST:GZNMI' : grupSec == '7' ? 'BIST:ISGSY' : grupSec == '8' ? 'BIST:KONYA' : grupSec == '9' ? 'BIST:MARBL' : grupSec == '10' ? 'BIST:OFSYM' : grupSec == '11' ? 'BIST:POLHO' : grupSec == '12' ? 'BIST:SILVR' : grupSec == '13' ? 'BIST:TNZTP' : grupSec == '14' ? 'BIST:YAYLA' : na
= request.security(a01, per, func())
= request.security(a02, per, func())
= request.security(a03, per, func())
= request.security(a04, per, func())
= request.security(a05, per, func())
= request.security(a06, per, func())
= request.security(a07, per, func())
= request.security(a08, per, func())
= request.security(a09, per, func())
= request.security(a10, per, func())
= request.security(a11, per, func())
= request.security(a12, per, func())
= request.security(a13, per, func())
= request.security(a14, per, func())
= request.security(a15, per, func())
= request.security(a16, per, func())
= request.security(a17, per, func())
= request.security(a18, per, func())
= request.security(a19, per, func())
= request.security(a20, per, func())
= request.security(a21, per, func())
= request.security(a22, per, func())
= request.security(a23, per, func())
= request.security(a24, per, func())
= request.security(a25, per, func())
= request.security(a26, per, func())
= request.security(a27, per, func())
= request.security(a28, per, func())
= request.security(a29, per, func())
= request.security(a30, per, func())
= request.security(a31, per, func())
= request.security(a32, per, func())
= request.security(a33, per, func())
= request.security(a34, per, func())
= request.security(a35, per, func())
= request.security(a36, per, func())
= request.security(a37, per, func())
= request.security(a38, per, func())
= request.security(a39, per, func())
= request.security(a40, per, func())
roundn(x, n) =>
mult = 1
if n != 0
for i = 1 to math.abs(n) by 1
mult *= 10
mult
n >= 0 ? math.round(x * mult) / mult : math.round(x / mult) * mult
scr_label = 'TARAMA\n'
scr_label := s1 ? scr_label + syminfo.ticker(a01) + ' ' + str.tostring(roundn(v1, 2)) + '\n' : scr_label
scr_label := s2 ? scr_label + syminfo.ticker(a02) + ' ' + str.tostring(roundn(v2, 2)) + '\n' : scr_label
scr_label := s3 ? scr_label + syminfo.ticker(a03) + ' ' + str.tostring(roundn(v3, 2)) + '\n' : scr_label
scr_label := s4 ? scr_label + syminfo.ticker(a04) + ' ' + str.tostring(roundn(v4, 2)) + '\n' : scr_label
scr_label := s5 ? scr_label + syminfo.ticker(a05) + ' ' + str.tostring(roundn(v5, 2)) + '\n' : scr_label
scr_label := s6 ? scr_label + syminfo.ticker(a06) + ' ' + str.tostring(roundn(v6, 2)) + '\n' : scr_label
scr_label := s7 ? scr_label + syminfo.ticker(a07) + ' ' + str.tostring(roundn(v7, 2)) + '\n' : scr_label
scr_label := s8 ? scr_label + syminfo.ticker(a08) + ' ' + str.tostring(roundn(v8, 2)) + '\n' : scr_label
scr_label := s9 ? scr_label + syminfo.ticker(a09) + ' ' + str.tostring(roundn(v9, 2)) + '\n' : scr_label
scr_label := s10 ? scr_label + syminfo.ticker(a10) + ' ' + str.tostring(roundn(v10, 2)) + '\n' : scr_label
scr_label := s11 ? scr_label + syminfo.ticker(a11) + ' ' + str.tostring(roundn(v11, 2)) + '\n' : scr_label
scr_label := s12 ? scr_label + syminfo.ticker(a12) + ' ' + str.tostring(roundn(v12, 2)) + '\n' : scr_label
scr_label := s13 ? scr_label + syminfo.ticker(a13) + ' ' + str.tostring(roundn(v13, 2)) + '\n' : scr_label
scr_label := s14 ? scr_label + syminfo.ticker(a14) + ' ' + str.tostring(roundn(v14, 2)) + '\n' : scr_label
scr_label := s15 ? scr_label + syminfo.ticker(a15) + ' ' + str.tostring(roundn(v15, 2)) + '\n' : scr_label
scr_label := s16 ? scr_label + syminfo.ticker(a16) + ' ' + str.tostring(roundn(v16, 2)) + '\n' : scr_label
scr_label := s17 ? scr_label + syminfo.ticker(a17) + ' ' + str.tostring(roundn(v17, 2)) + '\n' : scr_label
scr_label := s18 ? scr_label + syminfo.ticker(a18) + ' ' + str.tostring(roundn(v18, 2)) + '\n' : scr_label
scr_label := s19 ? scr_label + syminfo.ticker(a19) + ' ' + str.tostring(roundn(v19, 2)) + '\n' : scr_label
scr_label := s20 ? scr_label + syminfo.ticker(a20) + ' ' + str.tostring(roundn(v20, 2)) + '\n' : scr_label
scr_label := s21 ? scr_label + syminfo.ticker(a21) + ' ' + str.tostring(roundn(v21, 2)) + '\n' : scr_label
scr_label := s22 ? scr_label + syminfo.ticker(a22) + ' ' + str.tostring(roundn(v22, 2)) + '\n' : scr_label
scr_label := s23 ? scr_label + syminfo.ticker(a23) + ' ' + str.tostring(roundn(v23, 2)) + '\n' : scr_label
scr_label := s24 ? scr_label + syminfo.ticker(a24) + ' ' + str.tostring(roundn(v24, 2)) + '\n' : scr_label
scr_label := s25 ? scr_label + syminfo.ticker(a25) + ' ' + str.tostring(roundn(v25, 2)) + '\n' : scr_label
scr_label := s26 ? scr_label + syminfo.ticker(a26) + ' ' + str.tostring(roundn(v26, 2)) + '\n' : scr_label
scr_label := s27 ? scr_label + syminfo.ticker(a27) + ' ' + str.tostring(roundn(v27, 2)) + '\n' : scr_label
scr_label := s28 ? scr_label + syminfo.ticker(a28) + ' ' + str.tostring(roundn(v28, 2)) + '\n' : scr_label
scr_label := s29 ? scr_label + syminfo.ticker(a29) + ' ' + str.tostring(roundn(v29, 2)) + '\n' : scr_label
scr_label := s30 ? scr_label + syminfo.ticker(a30) + ' ' + str.tostring(roundn(v30, 2)) + '\n' : scr_label
scr_label := s31 ? scr_label + syminfo.ticker(a31) + ' ' + str.tostring(roundn(v31, 2)) + '\n' : scr_label
scr_label := s32 ? scr_label + syminfo.ticker(a32) + ' ' + str.tostring(roundn(v32, 2)) + '\n' : scr_label
scr_label := s33 ? scr_label + syminfo.ticker(a33) + ' ' + str.tostring(roundn(v33, 2)) + '\n' : scr_label
scr_label := s34 ? scr_label + syminfo.ticker(a34) + ' ' + str.tostring(roundn(v34, 2)) + '\n' : scr_label
scr_label := s35 ? scr_label + syminfo.ticker(a35) + ' ' + str.tostring(roundn(v35, 2)) + '\n' : scr_label
scr_label := s36 ? scr_label + syminfo.ticker(a36) + ' ' + str.tostring(roundn(v36, 2)) + '\n' : scr_label
scr_label := s37 ? scr_label + syminfo.ticker(a37) + ' ' + str.tostring(roundn(v37, 2)) + '\n' : scr_label
scr_label := s38 ? scr_label + syminfo.ticker(a38) + ' ' + str.tostring(roundn(v38, 2)) + '\n' : scr_label
scr_label := s39 ? scr_label + syminfo.ticker(a39) + ' ' + str.tostring(roundn(v39, 2)) + '\n' : scr_label
scr_label := s40 ? scr_label + syminfo.ticker(a40) + ' ' + str.tostring(roundn(v40, 2)) + '\n' : scr_label
var panel =table.new(position = position.top_right,columns = 10,rows=10,bgcolor = color.green,frame_color = color.black,border_color = color.red)
//lab_1 = label.new(bar_index + loc,50, scr_label, color=color.green, textcolor=color.white, style=label.style_label_center)
//label.delete(lab_1 )
if barstate.islast
table.cell(panel,0,0,text = str.tostring(scr_label))
if str.length(scr_label) > 8
alert(scr_label,alert.freq_once_per_bar_close)
//------------------------------------------------------
Analyst Targets ProbabilityThis indicator calculates the probability of the current stock price reaching or exceeding the analyst-provided high, average, and low price targets within a one-year time horizon. It utilizes a geometric Brownian motion (GBM) model, a standard approach in financial modeling that assumes log-normal price distribution with constant volatility.
### Key Features:
- **Analyst Targets**: Automatically pulls the high, average, and low one-year price targets from TradingView's syminfo data.
- **Risk-Free Rate**: Fetched from the 1-year US Treasury yield (symbol: TVC:US01Y). Defaults to 4% if unavailable.
- **Dividend Yield**: Uses trailing twelve-month (TTM) dividends per share (DPS) from financial data, divided by current price. Defaults to 0% if unavailable.
- **Volatility**: Computed as annualized historical volatility based on 252 trading days of daily log returns. Falls back to a 20-day period if insufficient data, or defaults to 30% if still unavailable.
- **Probability Calculation**: Employs the barrier hitting probability formula under GBM:
- Drift (μ) = risk-free rate - dividend yield - (volatility² / 2)
- The formula for probability P of hitting target H from current price S₀ over time T is:
P = Φ(d₊) + (H / S₀)^p ⋅ Φ(d₋) for H > S₀ (or adjusted for H < S₀)
Where l = ln(max(H, S₀)/min(H, S₀)), ν = drift, p = -2ν / σ², d₊ = (-l + νT) / (σ√T), d₋ = (-l - νT) / (σ√T), and Φ is the standard normal CDF (approximated using a polynomial method for accuracy).
- **Output Display**: A table in the top-right corner shows each target type, its value, and the estimated probability (as a percentage). "N/A" appears if data is unavailable or calculations cannot proceed (e.g., zero volatility).
### Assumptions and Limitations:
- Assumes constant volatility and drift, no transaction costs, and continuous trading (real markets may deviate due to jumps, news events, or changing conditions).
- Probabilities are model-based estimates and not guarantees; they represent the likelihood under risk-neutral measure.
- Best suited for stocks with available analyst targets and historical data; may default to assumptions for less-liquid symbols.
- No user inputs required—fully automated using TradingView's data sources.
This script is provided under the Mozilla Public License 2.0. For educational and informational purposes only; not financial advice. Test on your charts and consider backtesting for validation.
Composite Sentiment Indicator (SPY/QQQ/SOXX + VixFix)# Multi-Index Composite Sentiment Indicator
A comprehensive sentiment indicator that works across SPY, QQQ, SOXX, and custom symbols. Combines volatility, options flow, macro factors, technicals, and seasonality into a single z-score composite.
## What It Does
Takes multiple market sentiment inputs (VIX, put/call ratios, breadth, yields, etc.) and smooshes them into one normalized line. When the composite is high = markets getting spooked. When it's low = markets getting complacent.
## Key Features
- **Multi-Index Support**: Automatically adapts for SPY (uses VIX), QQQ (uses VXN), SOXX (uses VixFix), or custom symbols
- **VixFix Integration**: Larry Williams' VixFix for indices without dedicated VIX measures
- **Signal MA**: Choose from SMA/EMA/WMA/HMA/TEMA/DEMA with color coding (red above MA = risk-on, green below = risk-off)
- **September Focus**: Built-in seasonality weighting for September weakness patterns
- **Comprehensive Components**: Volatility, options sentiment, macro factors, technicals, and sector-specific metrics
## How to Use
**Basic Setup:**
1. Pick your index (SPY/QQQ/SOXX)
2. Choose signal MA type and length (EMA 21 is a good start)
3. Watch for extreme readings and MA crossovers
**Color Signals:**
- Red composite = above signal MA = bearish sentiment
- Green composite = below signal MA = bullish sentiment
- Extreme high readings (red background) = potential tops
- Extreme low readings (green background) = potential bottoms
**For Different Indices:**
- **QQQ**: Uses NASDAQ VIX (VXN) when available, falls back to VixFix
- **SOXX**: Includes semiconductor cycle indicators, uses VixFix for volatility
- **Custom**: Adapts automatically, relies on VixFix and general market metrics
## Components Included
**Volatility**: VIX/VXN/VixFix, term structure, historical vol
**Options**: Put/call ratios, SKEW index
**Macro**: DXY, 10Y yields, yield curve, TIPS spreads
**Technical**: RSI deviation, momentum
**Seasonality**: September effects, quad witching, month-end patterns
**Breadth**: S&P 500 and NASDAQ breadth measures
## Pro Tips
- Works well on Daily Timeframe
- September gets extra weight automatically - watch for August setup signals
- Keltner envelope breaks often mark sentiment exhaustion points
- Use alerts for extreme readings and MA crossovers
Works best when you understand that sentiment extremes often mark turning points, not continuation signals. High readings don't mean "keep shorting" - they mean "start looking for reversal setups."
## Settings Worth Tweaking
- Signal MA type/length for your timeframe
- Component weights based on what matters for your index
- Envelope multipliers for your risk tolerance
- VixFix parameters if default doesn't fit your symbol's volatility
The table shows all current component readings so you can see what's driving the signal. Good for context and debugging weird readings.
Universal Ratio Trend Matrix [InvestorUnknown]The Universal Ratio Trend Matrix is designed for trend analysis on asset/asset ratios, supporting up to 40 different assets. Its primary purpose is to help identify which assets are outperforming others within a selection, providing a broad overview of market trends through a matrix of ratios. The indicator automatically expands the matrix based on the number of assets chosen, simplifying the process of comparing multiple assets in terms of performance.
Key features include the ability to choose from a narrow selection of indicators to perform the ratio trend analysis, allowing users to apply well-defined metrics to their comparison.
Drawback: Due to the computational intensity involved in calculating ratios across many assets, the indicator has a limitation related to loading speed. TradingView has time limits for calculations, and for users on the basic (free) plan, this could result in frequent errors due to exceeded time limits. To use the indicator effectively, users with any paid plans should run it on timeframes higher than 8h (the lowest timeframe on which it managed to load with 40 assets), as lower timeframes may not reliably load.
Indicators:
RSI_raw: Simple function to calculate the Relative Strength Index (RSI) of a source (asset price).
RSI_sma: Calculates RSI followed by a Simple Moving Average (SMA).
RSI_ema: Calculates RSI followed by an Exponential Moving Average (EMA).
CCI: Calculates the Commodity Channel Index (CCI).
Fisher: Implements the Fisher Transform to normalize prices.
Utility Functions:
f_remove_exchange_name: Strips the exchange name from asset tickers (e.g., "INDEX:BTCUSD" to "BTCUSD").
f_remove_exchange_name(simple string name) =>
string parts = str.split(name, ":")
string result = array.size(parts) > 1 ? array.get(parts, 1) : name
result
f_get_price: Retrieves the closing price of a given asset ticker using request.security().
f_constant_src: Checks if the source data is constant by comparing multiple consecutive values.
Inputs:
General settings allow users to select the number of tickers for analysis (used_assets) and choose the trend indicator (RSI, CCI, Fisher, etc.).
Table settings customize how trend scores are displayed in terms of text size, header visibility, highlighting options, and top-performing asset identification.
The script includes inputs for up to 40 assets, allowing the user to select various cryptocurrencies (e.g., BTCUSD, ETHUSD, SOLUSD) or other assets for trend analysis.
Price Arrays:
Price values for each asset are stored in variables (price_a1 to price_a40) initialized as na. These prices are updated only for the number of assets specified by the user (used_assets).
Trend scores for each asset are stored in separate arrays
// declare price variables as "na"
var float price_a1 = na, var float price_a2 = na, var float price_a3 = na, var float price_a4 = na, var float price_a5 = na
var float price_a6 = na, var float price_a7 = na, var float price_a8 = na, var float price_a9 = na, var float price_a10 = na
var float price_a11 = na, var float price_a12 = na, var float price_a13 = na, var float price_a14 = na, var float price_a15 = na
var float price_a16 = na, var float price_a17 = na, var float price_a18 = na, var float price_a19 = na, var float price_a20 = na
var float price_a21 = na, var float price_a22 = na, var float price_a23 = na, var float price_a24 = na, var float price_a25 = na
var float price_a26 = na, var float price_a27 = na, var float price_a28 = na, var float price_a29 = na, var float price_a30 = na
var float price_a31 = na, var float price_a32 = na, var float price_a33 = na, var float price_a34 = na, var float price_a35 = na
var float price_a36 = na, var float price_a37 = na, var float price_a38 = na, var float price_a39 = na, var float price_a40 = na
// create "empty" arrays to store trend scores
var a1_array = array.new_int(40, 0), var a2_array = array.new_int(40, 0), var a3_array = array.new_int(40, 0), var a4_array = array.new_int(40, 0)
var a5_array = array.new_int(40, 0), var a6_array = array.new_int(40, 0), var a7_array = array.new_int(40, 0), var a8_array = array.new_int(40, 0)
var a9_array = array.new_int(40, 0), var a10_array = array.new_int(40, 0), var a11_array = array.new_int(40, 0), var a12_array = array.new_int(40, 0)
var a13_array = array.new_int(40, 0), var a14_array = array.new_int(40, 0), var a15_array = array.new_int(40, 0), var a16_array = array.new_int(40, 0)
var a17_array = array.new_int(40, 0), var a18_array = array.new_int(40, 0), var a19_array = array.new_int(40, 0), var a20_array = array.new_int(40, 0)
var a21_array = array.new_int(40, 0), var a22_array = array.new_int(40, 0), var a23_array = array.new_int(40, 0), var a24_array = array.new_int(40, 0)
var a25_array = array.new_int(40, 0), var a26_array = array.new_int(40, 0), var a27_array = array.new_int(40, 0), var a28_array = array.new_int(40, 0)
var a29_array = array.new_int(40, 0), var a30_array = array.new_int(40, 0), var a31_array = array.new_int(40, 0), var a32_array = array.new_int(40, 0)
var a33_array = array.new_int(40, 0), var a34_array = array.new_int(40, 0), var a35_array = array.new_int(40, 0), var a36_array = array.new_int(40, 0)
var a37_array = array.new_int(40, 0), var a38_array = array.new_int(40, 0), var a39_array = array.new_int(40, 0), var a40_array = array.new_int(40, 0)
f_get_price(simple string ticker) =>
request.security(ticker, "", close)
// Prices for each USED asset
f_get_asset_price(asset_number, ticker) =>
if (used_assets >= asset_number)
f_get_price(ticker)
else
na
// overwrite empty variables with the prices if "used_assets" is greater or equal to the asset number
if barstate.isconfirmed // use barstate.isconfirmed to avoid "na prices" and calculation errors that result in empty cells in the table
price_a1 := f_get_asset_price(1, asset1), price_a2 := f_get_asset_price(2, asset2), price_a3 := f_get_asset_price(3, asset3), price_a4 := f_get_asset_price(4, asset4)
price_a5 := f_get_asset_price(5, asset5), price_a6 := f_get_asset_price(6, asset6), price_a7 := f_get_asset_price(7, asset7), price_a8 := f_get_asset_price(8, asset8)
price_a9 := f_get_asset_price(9, asset9), price_a10 := f_get_asset_price(10, asset10), price_a11 := f_get_asset_price(11, asset11), price_a12 := f_get_asset_price(12, asset12)
price_a13 := f_get_asset_price(13, asset13), price_a14 := f_get_asset_price(14, asset14), price_a15 := f_get_asset_price(15, asset15), price_a16 := f_get_asset_price(16, asset16)
price_a17 := f_get_asset_price(17, asset17), price_a18 := f_get_asset_price(18, asset18), price_a19 := f_get_asset_price(19, asset19), price_a20 := f_get_asset_price(20, asset20)
price_a21 := f_get_asset_price(21, asset21), price_a22 := f_get_asset_price(22, asset22), price_a23 := f_get_asset_price(23, asset23), price_a24 := f_get_asset_price(24, asset24)
price_a25 := f_get_asset_price(25, asset25), price_a26 := f_get_asset_price(26, asset26), price_a27 := f_get_asset_price(27, asset27), price_a28 := f_get_asset_price(28, asset28)
price_a29 := f_get_asset_price(29, asset29), price_a30 := f_get_asset_price(30, asset30), price_a31 := f_get_asset_price(31, asset31), price_a32 := f_get_asset_price(32, asset32)
price_a33 := f_get_asset_price(33, asset33), price_a34 := f_get_asset_price(34, asset34), price_a35 := f_get_asset_price(35, asset35), price_a36 := f_get_asset_price(36, asset36)
price_a37 := f_get_asset_price(37, asset37), price_a38 := f_get_asset_price(38, asset38), price_a39 := f_get_asset_price(39, asset39), price_a40 := f_get_asset_price(40, asset40)
Universal Indicator Calculation (f_calc_score):
This function allows switching between different trend indicators (RSI, CCI, Fisher) for flexibility.
It uses a switch-case structure to calculate the indicator score, where a positive trend is denoted by 1 and a negative trend by 0. Each indicator has its own logic to determine whether the asset is trending up or down.
// use switch to allow "universality" in indicator selection
f_calc_score(source, trend_indicator, int_1, int_2) =>
int score = na
if (not f_constant_src(source)) and source > 0.0 // Skip if you are using the same assets for ratio (for example BTC/BTC)
x = switch trend_indicator
"RSI (Raw)" => RSI_raw(source, int_1)
"RSI (SMA)" => RSI_sma(source, int_1, int_2)
"RSI (EMA)" => RSI_ema(source, int_1, int_2)
"CCI" => CCI(source, int_1)
"Fisher" => Fisher(source, int_1)
y = switch trend_indicator
"RSI (Raw)" => x > 50 ? 1 : 0
"RSI (SMA)" => x > 50 ? 1 : 0
"RSI (EMA)" => x > 50 ? 1 : 0
"CCI" => x > 0 ? 1 : 0
"Fisher" => x > x ? 1 : 0
score := y
else
score := 0
score
Array Setting Function (f_array_set):
This function populates an array with scores calculated for each asset based on a base price (p_base) divided by the prices of the individual assets.
It processes multiple assets (up to 40), calling the f_calc_score function for each.
// function to set values into the arrays
f_array_set(a_array, p_base) =>
array.set(a_array, 0, f_calc_score(p_base / price_a1, trend_indicator, int_1, int_2))
array.set(a_array, 1, f_calc_score(p_base / price_a2, trend_indicator, int_1, int_2))
array.set(a_array, 2, f_calc_score(p_base / price_a3, trend_indicator, int_1, int_2))
array.set(a_array, 3, f_calc_score(p_base / price_a4, trend_indicator, int_1, int_2))
array.set(a_array, 4, f_calc_score(p_base / price_a5, trend_indicator, int_1, int_2))
array.set(a_array, 5, f_calc_score(p_base / price_a6, trend_indicator, int_1, int_2))
array.set(a_array, 6, f_calc_score(p_base / price_a7, trend_indicator, int_1, int_2))
array.set(a_array, 7, f_calc_score(p_base / price_a8, trend_indicator, int_1, int_2))
array.set(a_array, 8, f_calc_score(p_base / price_a9, trend_indicator, int_1, int_2))
array.set(a_array, 9, f_calc_score(p_base / price_a10, trend_indicator, int_1, int_2))
array.set(a_array, 10, f_calc_score(p_base / price_a11, trend_indicator, int_1, int_2))
array.set(a_array, 11, f_calc_score(p_base / price_a12, trend_indicator, int_1, int_2))
array.set(a_array, 12, f_calc_score(p_base / price_a13, trend_indicator, int_1, int_2))
array.set(a_array, 13, f_calc_score(p_base / price_a14, trend_indicator, int_1, int_2))
array.set(a_array, 14, f_calc_score(p_base / price_a15, trend_indicator, int_1, int_2))
array.set(a_array, 15, f_calc_score(p_base / price_a16, trend_indicator, int_1, int_2))
array.set(a_array, 16, f_calc_score(p_base / price_a17, trend_indicator, int_1, int_2))
array.set(a_array, 17, f_calc_score(p_base / price_a18, trend_indicator, int_1, int_2))
array.set(a_array, 18, f_calc_score(p_base / price_a19, trend_indicator, int_1, int_2))
array.set(a_array, 19, f_calc_score(p_base / price_a20, trend_indicator, int_1, int_2))
array.set(a_array, 20, f_calc_score(p_base / price_a21, trend_indicator, int_1, int_2))
array.set(a_array, 21, f_calc_score(p_base / price_a22, trend_indicator, int_1, int_2))
array.set(a_array, 22, f_calc_score(p_base / price_a23, trend_indicator, int_1, int_2))
array.set(a_array, 23, f_calc_score(p_base / price_a24, trend_indicator, int_1, int_2))
array.set(a_array, 24, f_calc_score(p_base / price_a25, trend_indicator, int_1, int_2))
array.set(a_array, 25, f_calc_score(p_base / price_a26, trend_indicator, int_1, int_2))
array.set(a_array, 26, f_calc_score(p_base / price_a27, trend_indicator, int_1, int_2))
array.set(a_array, 27, f_calc_score(p_base / price_a28, trend_indicator, int_1, int_2))
array.set(a_array, 28, f_calc_score(p_base / price_a29, trend_indicator, int_1, int_2))
array.set(a_array, 29, f_calc_score(p_base / price_a30, trend_indicator, int_1, int_2))
array.set(a_array, 30, f_calc_score(p_base / price_a31, trend_indicator, int_1, int_2))
array.set(a_array, 31, f_calc_score(p_base / price_a32, trend_indicator, int_1, int_2))
array.set(a_array, 32, f_calc_score(p_base / price_a33, trend_indicator, int_1, int_2))
array.set(a_array, 33, f_calc_score(p_base / price_a34, trend_indicator, int_1, int_2))
array.set(a_array, 34, f_calc_score(p_base / price_a35, trend_indicator, int_1, int_2))
array.set(a_array, 35, f_calc_score(p_base / price_a36, trend_indicator, int_1, int_2))
array.set(a_array, 36, f_calc_score(p_base / price_a37, trend_indicator, int_1, int_2))
array.set(a_array, 37, f_calc_score(p_base / price_a38, trend_indicator, int_1, int_2))
array.set(a_array, 38, f_calc_score(p_base / price_a39, trend_indicator, int_1, int_2))
array.set(a_array, 39, f_calc_score(p_base / price_a40, trend_indicator, int_1, int_2))
a_array
Conditional Array Setting (f_arrayset):
This function checks if the number of used assets is greater than or equal to a specified number before populating the arrays.
// only set values into arrays for USED assets
f_arrayset(asset_number, a_array, p_base) =>
if (used_assets >= asset_number)
f_array_set(a_array, p_base)
else
na
Main Logic
The main logic initializes arrays to store scores for each asset. Each array corresponds to one asset's performance score.
Setting Trend Values: The code calls f_arrayset for each asset, populating the respective arrays with calculated scores based on the asset prices.
Combining Arrays: A combined_array is created to hold all the scores from individual asset arrays. This array facilitates further analysis, allowing for an overview of the performance scores of all assets at once.
// create a combined array (work-around since pinescript doesn't support having array of arrays)
var combined_array = array.new_int(40 * 40, 0)
if barstate.islast
for i = 0 to 39
array.set(combined_array, i, array.get(a1_array, i))
array.set(combined_array, i + (40 * 1), array.get(a2_array, i))
array.set(combined_array, i + (40 * 2), array.get(a3_array, i))
array.set(combined_array, i + (40 * 3), array.get(a4_array, i))
array.set(combined_array, i + (40 * 4), array.get(a5_array, i))
array.set(combined_array, i + (40 * 5), array.get(a6_array, i))
array.set(combined_array, i + (40 * 6), array.get(a7_array, i))
array.set(combined_array, i + (40 * 7), array.get(a8_array, i))
array.set(combined_array, i + (40 * 8), array.get(a9_array, i))
array.set(combined_array, i + (40 * 9), array.get(a10_array, i))
array.set(combined_array, i + (40 * 10), array.get(a11_array, i))
array.set(combined_array, i + (40 * 11), array.get(a12_array, i))
array.set(combined_array, i + (40 * 12), array.get(a13_array, i))
array.set(combined_array, i + (40 * 13), array.get(a14_array, i))
array.set(combined_array, i + (40 * 14), array.get(a15_array, i))
array.set(combined_array, i + (40 * 15), array.get(a16_array, i))
array.set(combined_array, i + (40 * 16), array.get(a17_array, i))
array.set(combined_array, i + (40 * 17), array.get(a18_array, i))
array.set(combined_array, i + (40 * 18), array.get(a19_array, i))
array.set(combined_array, i + (40 * 19), array.get(a20_array, i))
array.set(combined_array, i + (40 * 20), array.get(a21_array, i))
array.set(combined_array, i + (40 * 21), array.get(a22_array, i))
array.set(combined_array, i + (40 * 22), array.get(a23_array, i))
array.set(combined_array, i + (40 * 23), array.get(a24_array, i))
array.set(combined_array, i + (40 * 24), array.get(a25_array, i))
array.set(combined_array, i + (40 * 25), array.get(a26_array, i))
array.set(combined_array, i + (40 * 26), array.get(a27_array, i))
array.set(combined_array, i + (40 * 27), array.get(a28_array, i))
array.set(combined_array, i + (40 * 28), array.get(a29_array, i))
array.set(combined_array, i + (40 * 29), array.get(a30_array, i))
array.set(combined_array, i + (40 * 30), array.get(a31_array, i))
array.set(combined_array, i + (40 * 31), array.get(a32_array, i))
array.set(combined_array, i + (40 * 32), array.get(a33_array, i))
array.set(combined_array, i + (40 * 33), array.get(a34_array, i))
array.set(combined_array, i + (40 * 34), array.get(a35_array, i))
array.set(combined_array, i + (40 * 35), array.get(a36_array, i))
array.set(combined_array, i + (40 * 36), array.get(a37_array, i))
array.set(combined_array, i + (40 * 37), array.get(a38_array, i))
array.set(combined_array, i + (40 * 38), array.get(a39_array, i))
array.set(combined_array, i + (40 * 39), array.get(a40_array, i))
Calculating Sums: A separate array_sums is created to store the total score for each asset by summing the values of their respective score arrays. This allows for easy comparison of overall performance.
Ranking Assets: The final part of the code ranks the assets based on their total scores stored in array_sums. It assigns a rank to each asset, where the asset with the highest score receives the highest rank.
// create array for asset RANK based on array.sum
var ranks = array.new_int(used_assets, 0)
// for loop that calculates the rank of each asset
if barstate.islast
for i = 0 to (used_assets - 1)
int rank = 1
for x = 0 to (used_assets - 1)
if i != x
if array.get(array_sums, i) < array.get(array_sums, x)
rank := rank + 1
array.set(ranks, i, rank)
Dynamic Table Creation
Initialization: The table is initialized with a base structure that includes headers for asset names, scores, and ranks. The headers are set to remain constant, ensuring clarity for users as they interpret the displayed data.
Data Population: As scores are calculated for each asset, the corresponding values are dynamically inserted into the table. This is achieved through a loop that iterates over the scores and ranks stored in the combined_array and array_sums, respectively.
Automatic Extending Mechanism
Variable Asset Count: The code checks the number of assets defined by the user. Instead of hardcoding the number of rows in the table, it uses a variable to determine the extent of the data that needs to be displayed. This allows the table to expand or contract based on the number of assets being analyzed.
Dynamic Row Generation: Within the loop that populates the table, the code appends new rows for each asset based on the current asset count. The structure of each row includes the asset name, its score, and its rank, ensuring that the table remains consistent regardless of how many assets are involved.
// Automatically extending table based on the number of used assets
var table table = table.new(position.bottom_center, 50, 50, color.new(color.black, 100), color.white, 3, color.white, 1)
if barstate.islast
if not hide_head
table.cell(table, 0, 0, "Universal Ratio Trend Matrix", text_color = color.white, bgcolor = #010c3b, text_size = fontSize)
table.merge_cells(table, 0, 0, used_assets + 3, 0)
if not hide_inps
table.cell(table, 0, 1,
text = "Inputs: You are using " + str.tostring(trend_indicator) + ", which takes: " + str.tostring(f_get_input(trend_indicator)),
text_color = color.white, text_size = fontSize), table.merge_cells(table, 0, 1, used_assets + 3, 1)
table.cell(table, 0, 2, "Assets", text_color = color.white, text_size = fontSize, bgcolor = #010c3b)
for x = 0 to (used_assets - 1)
table.cell(table, x + 1, 2, text = str.tostring(array.get(assets, x)), text_color = color.white, bgcolor = #010c3b, text_size = fontSize)
table.cell(table, 0, x + 3, text = str.tostring(array.get(assets, x)), text_color = color.white, bgcolor = f_asset_col(array.get(ranks, x)), text_size = fontSize)
for r = 0 to (used_assets - 1)
for c = 0 to (used_assets - 1)
table.cell(table, c + 1, r + 3, text = str.tostring(array.get(combined_array, c + (r * 40))),
text_color = hl_type == "Text" ? f_get_col(array.get(combined_array, c + (r * 40))) : color.white, text_size = fontSize,
bgcolor = hl_type == "Background" ? f_get_col(array.get(combined_array, c + (r * 40))) : na)
for x = 0 to (used_assets - 1)
table.cell(table, x + 1, x + 3, "", bgcolor = #010c3b)
table.cell(table, used_assets + 1, 2, "", bgcolor = #010c3b)
for x = 0 to (used_assets - 1)
table.cell(table, used_assets + 1, x + 3, "==>", text_color = color.white)
table.cell(table, used_assets + 2, 2, "SUM", text_color = color.white, text_size = fontSize, bgcolor = #010c3b)
table.cell(table, used_assets + 3, 2, "RANK", text_color = color.white, text_size = fontSize, bgcolor = #010c3b)
for x = 0 to (used_assets - 1)
table.cell(table, used_assets + 2, x + 3,
text = str.tostring(array.get(array_sums, x)),
text_color = color.white, text_size = fontSize,
bgcolor = f_highlight_sum(array.get(array_sums, x), array.get(ranks, x)))
table.cell(table, used_assets + 3, x + 3,
text = str.tostring(array.get(ranks, x)),
text_color = color.white, text_size = fontSize,
bgcolor = f_highlight_rank(array.get(ranks, x)))
Markov Chain [3D] | FractalystWhat exactly is a Markov Chain?
This indicator uses a Markov Chain model to analyze, quantify, and visualize the transitions between market regimes (Bull, Bear, Neutral) on your chart. It dynamically detects these regimes in real-time, calculates transition probabilities, and displays them as animated 3D spheres and arrows, giving traders intuitive insight into current and future market conditions.
How does a Markov Chain work, and how should I read this spheres-and-arrows diagram?
Think of three weather modes: Sunny, Rainy, Cloudy.
Each sphere is one mode. The loop on a sphere means “stay the same next step” (e.g., Sunny again tomorrow).
The arrows leaving a sphere show where things usually go next if they change (e.g., Sunny moving to Cloudy).
Some paths matter more than others. A more prominent loop means the current mode tends to persist. A more prominent outgoing arrow means a change to that destination is the usual next step.
Direction isn’t symmetric: moving Sunny→Cloudy can behave differently than Cloudy→Sunny.
Now relabel the spheres to markets: Bull, Bear, Neutral.
Spheres: market regimes (uptrend, downtrend, range).
Self‑loop: tendency for the current regime to continue on the next bar.
Arrows: the most common next regime if a switch happens.
How to read: Start at the sphere that matches current bar state. If the loop stands out, expect continuation. If one outgoing path stands out, that switch is the typical next step. Opposite directions can differ (Bear→Neutral doesn’t have to match Neutral→Bear).
What states and transitions are shown?
The three market states visualized are:
Bullish (Bull): Upward or strong-market regime.
Bearish (Bear): Downward or weak-market regime.
Neutral: Sideways or range-bound regime.
Bidirectional animated arrows and probability labels show how likely the market is to move from one regime to another (e.g., Bull → Bear or Neutral → Bull).
How does the regime detection system work?
You can use either built-in price returns (based on adaptive Z-score normalization) or supply three custom indicators (such as volume, oscillators, etc.).
Values are statistically normalized (Z-scored) over a configurable lookback period.
The normalized outputs are classified into Bull, Bear, or Neutral zones.
If using three indicators, their regime signals are averaged and smoothed for robustness.
How are transition probabilities calculated?
On every confirmed bar, the algorithm tracks the sequence of detected market states, then builds a rolling window of transitions.
The code maintains a transition count matrix for all regime pairs (e.g., Bull → Bear).
Transition probabilities are extracted for each possible state change using Laplace smoothing for numerical stability, and frequently updated in real-time.
What is unique about the visualization?
3D animated spheres represent each regime and change visually when active.
Animated, bidirectional arrows reveal transition probabilities and allow you to see both dominant and less likely regime flows.
Particles (moving dots) animate along the arrows, enhancing the perception of regime flow direction and speed.
All elements dynamically update with each new price bar, providing a live market map in an intuitive, engaging format.
Can I use custom indicators for regime classification?
Yes! Enable the "Custom Indicators" switch and select any three chart series as inputs. These will be normalized and combined (each with equal weight), broadening the regime classification beyond just price-based movement.
What does the “Lookback Period” control?
Lookback Period (default: 100) sets how much historical data builds the probability matrix. Shorter periods adapt faster to regime changes but may be noisier. Longer periods are more stable but slower to adapt.
How is this different from a Hidden Markov Model (HMM)?
It sets the window for both regime detection and probability calculations. Lower values make the system more reactive, but potentially noisier. Higher values smooth estimates and make the system more robust.
How is this Markov Chain different from a Hidden Markov Model (HMM)?
Markov Chain (as here): All market regimes (Bull, Bear, Neutral) are directly observable on the chart. The transition matrix is built from actual detected regimes, keeping the model simple and interpretable.
Hidden Markov Model: The actual regimes are unobservable ("hidden") and must be inferred from market output or indicator "emissions" using statistical learning algorithms. HMMs are more complex, can capture more subtle structure, but are harder to visualize and require additional machine learning steps for training.
A standard Markov Chain models transitions between observable states using a simple transition matrix, while a Hidden Markov Model assumes the true states are hidden (latent) and must be inferred from observable “emissions” like price or volume data. In practical terms, a Markov Chain is transparent and easier to implement and interpret; an HMM is more expressive but requires statistical inference to estimate hidden states from data.
Markov Chain: states are observable; you directly count or estimate transition probabilities between visible states. This makes it simpler, faster, and easier to validate and tune.
HMM: states are hidden; you only observe emissions generated by those latent states. Learning involves machine learning/statistical algorithms (commonly Baum–Welch/EM for training and Viterbi for decoding) to infer both the transition dynamics and the most likely hidden state sequence from data.
How does the indicator avoid “repainting” or look-ahead bias?
All regime changes and matrix updates happen only on confirmed (closed) bars, so no future data is leaked, ensuring reliable real-time operation.
Are there practical tuning tips?
Tune the Lookback Period for your asset/timeframe: shorter for fast markets, longer for stability.
Use custom indicators if your asset has unique regime drivers.
Watch for rapid changes in transition probabilities as early warning of a possible regime shift.
Who is this indicator for?
Quants and quantitative researchers exploring probabilistic market modeling, especially those interested in regime-switching dynamics and Markov models.
Programmers and system developers who need a probabilistic regime filter for systematic and algorithmic backtesting:
The Markov Chain indicator is ideally suited for programmatic integration via its bias output (1 = Bull, 0 = Neutral, -1 = Bear).
Although the visualization is engaging, the core output is designed for automated, rules-based workflows—not for discretionary/manual trading decisions.
Developers can connect the indicator’s output directly to their Pine Script logic (using input.source()), allowing rapid and robust backtesting of regime-based strategies.
It acts as a plug-and-play regime filter: simply plug the bias output into your entry/exit logic, and you have a scientifically robust, probabilistically-derived signal for filtering, timing, position sizing, or risk regimes.
The MC's output is intentionally "trinary" (1/0/-1), focusing on clear regime states for unambiguous decision-making in code. If you require nuanced, multi-probability or soft-label state vectors, consider expanding the indicator or stacking it with a probability-weighted logic layer in your scripting.
Because it avoids subjectivity, this approach is optimal for systematic quants, algo developers building backtested, repeatable strategies based on probabilistic regime analysis.
What's the mathematical foundation behind this?
The mathematical foundation behind this Markov Chain indicator—and probabilistic regime detection in finance—draws from two principal models: the (standard) Markov Chain and the Hidden Markov Model (HMM).
How to use this indicator programmatically?
The Markov Chain indicator automatically exports a bias value (+1 for Bullish, -1 for Bearish, 0 for Neutral) as a plot visible in the Data Window. This allows you to integrate its regime signal into your own scripts and strategies for backtesting, automation, or live trading.
Step-by-Step Integration with Pine Script (input.source)
Add the Markov Chain indicator to your chart.
This must be done first, since your custom script will "pull" the bias signal from the indicator's plot.
In your strategy, create an input using input.source()
Example:
//@version=5
strategy("MC Bias Strategy Example")
mcBias = input.source(close, "MC Bias Source")
After saving, go to your script’s settings. For the “MC Bias Source” input, select the plot/output of the Markov Chain indicator (typically its bias plot).
Use the bias in your trading logic
Example (long only on Bull, flat otherwise):
if mcBias == 1
strategy.entry("Long", strategy.long)
else
strategy.close("Long")
For more advanced workflows, combine mcBias with additional filters or trailing stops.
How does this work behind-the-scenes?
TradingView’s input.source() lets you use any plot from another indicator as a real-time, “live” data feed in your own script (source).
The selected bias signal is available to your Pine code as a variable, enabling logical decisions based on regime (trend-following, mean-reversion, etc.).
This enables powerful strategy modularity : decouple regime detection from entry/exit logic, allowing fast experimentation without rewriting core signal code.
Integrating 45+ Indicators with Your Markov Chain — How & Why
The Enhanced Custom Indicators Export script exports a massive suite of over 45 technical indicators—ranging from classic momentum (RSI, MACD, Stochastic, etc.) to trend, volume, volatility, and oscillator tools—all pre-calculated, centered/scaled, and available as plots.
// Enhanced Custom Indicators Export - 45 Technical Indicators
// Comprehensive technical analysis suite for advanced market regime detection
//@version=6
indicator('Enhanced Custom Indicators Export | Fractalyst', shorttitle='Enhanced CI Export', overlay=false, scale=scale.right, max_labels_count=500, max_lines_count=500)
// |----- Input Parameters -----| //
momentum_group = "Momentum Indicators"
trend_group = "Trend Indicators"
volume_group = "Volume Indicators"
volatility_group = "Volatility Indicators"
oscillator_group = "Oscillator Indicators"
display_group = "Display Settings"
// Common lengths
length_14 = input.int(14, "Standard Length (14)", minval=1, maxval=100, group=momentum_group)
length_20 = input.int(20, "Medium Length (20)", minval=1, maxval=200, group=trend_group)
length_50 = input.int(50, "Long Length (50)", minval=1, maxval=200, group=trend_group)
// Display options
show_table = input.bool(true, "Show Values Table", group=display_group)
table_size = input.string("Small", "Table Size", options= , group=display_group)
// |----- MOMENTUM INDICATORS (15 indicators) -----| //
// 1. RSI (Relative Strength Index)
rsi_14 = ta.rsi(close, length_14)
rsi_centered = rsi_14 - 50
// 2. Stochastic Oscillator
stoch_k = ta.stoch(close, high, low, length_14)
stoch_d = ta.sma(stoch_k, 3)
stoch_centered = stoch_k - 50
// 3. Williams %R
williams_r = ta.stoch(close, high, low, length_14) - 100
// 4. MACD (Moving Average Convergence Divergence)
= ta.macd(close, 12, 26, 9)
// 5. Momentum (Rate of Change)
momentum = ta.mom(close, length_14)
momentum_pct = (momentum / close ) * 100
// 6. Rate of Change (ROC)
roc = ta.roc(close, length_14)
// 7. Commodity Channel Index (CCI)
cci = ta.cci(close, length_20)
// 8. Money Flow Index (MFI)
mfi = ta.mfi(close, length_14)
mfi_centered = mfi - 50
// 9. Awesome Oscillator (AO)
ao = ta.sma(hl2, 5) - ta.sma(hl2, 34)
// 10. Accelerator Oscillator (AC)
ac = ao - ta.sma(ao, 5)
// 11. Chande Momentum Oscillator (CMO)
cmo = ta.cmo(close, length_14)
// 12. Detrended Price Oscillator (DPO)
dpo = close - ta.sma(close, length_20)
// 13. Price Oscillator (PPO)
ppo = ta.sma(close, 12) - ta.sma(close, 26)
ppo_pct = (ppo / ta.sma(close, 26)) * 100
// 14. TRIX
trix_ema1 = ta.ema(close, length_14)
trix_ema2 = ta.ema(trix_ema1, length_14)
trix_ema3 = ta.ema(trix_ema2, length_14)
trix = ta.roc(trix_ema3, 1) * 10000
// 15. Klinger Oscillator
klinger = ta.ema(volume * (high + low + close) / 3, 34) - ta.ema(volume * (high + low + close) / 3, 55)
// 16. Fisher Transform
fisher_hl2 = 0.5 * (hl2 - ta.lowest(hl2, 10)) / (ta.highest(hl2, 10) - ta.lowest(hl2, 10)) - 0.25
fisher = 0.5 * math.log((1 + fisher_hl2) / (1 - fisher_hl2))
// 17. Stochastic RSI
stoch_rsi = ta.stoch(rsi_14, rsi_14, rsi_14, length_14)
stoch_rsi_centered = stoch_rsi - 50
// 18. Relative Vigor Index (RVI)
rvi_num = ta.swma(close - open)
rvi_den = ta.swma(high - low)
rvi = rvi_den != 0 ? rvi_num / rvi_den : 0
// 19. Balance of Power (BOP)
bop = (close - open) / (high - low)
// |----- TREND INDICATORS (10 indicators) -----| //
// 20. Simple Moving Average Momentum
sma_20 = ta.sma(close, length_20)
sma_momentum = ((close - sma_20) / sma_20) * 100
// 21. Exponential Moving Average Momentum
ema_20 = ta.ema(close, length_20)
ema_momentum = ((close - ema_20) / ema_20) * 100
// 22. Parabolic SAR
sar = ta.sar(0.02, 0.02, 0.2)
sar_trend = close > sar ? 1 : -1
// 23. Linear Regression Slope
lr_slope = ta.linreg(close, length_20, 0) - ta.linreg(close, length_20, 1)
// 24. Moving Average Convergence (MAC)
mac = ta.sma(close, 10) - ta.sma(close, 30)
// 25. Trend Intensity Index (TII)
tii_sum = 0.0
for i = 1 to length_20
tii_sum += close > close ? 1 : 0
tii = (tii_sum / length_20) * 100
// 26. Ichimoku Cloud Components
ichimoku_tenkan = (ta.highest(high, 9) + ta.lowest(low, 9)) / 2
ichimoku_kijun = (ta.highest(high, 26) + ta.lowest(low, 26)) / 2
ichimoku_signal = ichimoku_tenkan > ichimoku_kijun ? 1 : -1
// 27. MESA Adaptive Moving Average (MAMA)
mama_alpha = 2.0 / (length_20 + 1)
mama = ta.ema(close, length_20)
mama_momentum = ((close - mama) / mama) * 100
// 28. Zero Lag Exponential Moving Average (ZLEMA)
zlema_lag = math.round((length_20 - 1) / 2)
zlema_data = close + (close - close )
zlema = ta.ema(zlema_data, length_20)
zlema_momentum = ((close - zlema) / zlema) * 100
// |----- VOLUME INDICATORS (6 indicators) -----| //
// 29. On-Balance Volume (OBV)
obv = ta.obv
// 30. Volume Rate of Change (VROC)
vroc = ta.roc(volume, length_14)
// 31. Price Volume Trend (PVT)
pvt = ta.pvt
// 32. Negative Volume Index (NVI)
nvi = 0.0
nvi := volume < volume ? nvi + ((close - close ) / close ) * nvi : nvi
// 33. Positive Volume Index (PVI)
pvi = 0.0
pvi := volume > volume ? pvi + ((close - close ) / close ) * pvi : pvi
// 34. Volume Oscillator
vol_osc = ta.sma(volume, 5) - ta.sma(volume, 10)
// 35. Ease of Movement (EOM)
eom_distance = high - low
eom_box_height = volume / 1000000
eom = eom_box_height != 0 ? eom_distance / eom_box_height : 0
eom_sma = ta.sma(eom, length_14)
// 36. Force Index
force_index = volume * (close - close )
force_index_sma = ta.sma(force_index, length_14)
// |----- VOLATILITY INDICATORS (10 indicators) -----| //
// 37. Average True Range (ATR)
atr = ta.atr(length_14)
atr_pct = (atr / close) * 100
// 38. Bollinger Bands Position
bb_basis = ta.sma(close, length_20)
bb_dev = 2.0 * ta.stdev(close, length_20)
bb_upper = bb_basis + bb_dev
bb_lower = bb_basis - bb_dev
bb_position = bb_dev != 0 ? (close - bb_basis) / bb_dev : 0
bb_width = bb_dev != 0 ? (bb_upper - bb_lower) / bb_basis * 100 : 0
// 39. Keltner Channels Position
kc_basis = ta.ema(close, length_20)
kc_range = ta.ema(ta.tr, length_20)
kc_upper = kc_basis + (2.0 * kc_range)
kc_lower = kc_basis - (2.0 * kc_range)
kc_position = kc_range != 0 ? (close - kc_basis) / kc_range : 0
// 40. Donchian Channels Position
dc_upper = ta.highest(high, length_20)
dc_lower = ta.lowest(low, length_20)
dc_basis = (dc_upper + dc_lower) / 2
dc_position = (dc_upper - dc_lower) != 0 ? (close - dc_basis) / (dc_upper - dc_lower) : 0
// 41. Standard Deviation
std_dev = ta.stdev(close, length_20)
std_dev_pct = (std_dev / close) * 100
// 42. Relative Volatility Index (RVI)
rvi_up = ta.stdev(close > close ? close : 0, length_14)
rvi_down = ta.stdev(close < close ? close : 0, length_14)
rvi_total = rvi_up + rvi_down
rvi_volatility = rvi_total != 0 ? (rvi_up / rvi_total) * 100 : 50
// 43. Historical Volatility
hv_returns = math.log(close / close )
hv = ta.stdev(hv_returns, length_20) * math.sqrt(252) * 100
// 44. Garman-Klass Volatility
gk_vol = math.log(high/low) * math.log(high/low) - (2*math.log(2)-1) * math.log(close/open) * math.log(close/open)
gk_volatility = math.sqrt(ta.sma(gk_vol, length_20)) * 100
// 45. Parkinson Volatility
park_vol = math.log(high/low) * math.log(high/low)
parkinson = math.sqrt(ta.sma(park_vol, length_20) / (4 * math.log(2))) * 100
// 46. Rogers-Satchell Volatility
rs_vol = math.log(high/close) * math.log(high/open) + math.log(low/close) * math.log(low/open)
rogers_satchell = math.sqrt(ta.sma(rs_vol, length_20)) * 100
// |----- OSCILLATOR INDICATORS (5 indicators) -----| //
// 47. Elder Ray Index
elder_bull = high - ta.ema(close, 13)
elder_bear = low - ta.ema(close, 13)
elder_power = elder_bull + elder_bear
// 48. Schaff Trend Cycle (STC)
stc_macd = ta.ema(close, 23) - ta.ema(close, 50)
stc_k = ta.stoch(stc_macd, stc_macd, stc_macd, 10)
stc_d = ta.ema(stc_k, 3)
stc = ta.stoch(stc_d, stc_d, stc_d, 10)
// 49. Coppock Curve
coppock_roc1 = ta.roc(close, 14)
coppock_roc2 = ta.roc(close, 11)
coppock = ta.wma(coppock_roc1 + coppock_roc2, 10)
// 50. Know Sure Thing (KST)
kst_roc1 = ta.roc(close, 10)
kst_roc2 = ta.roc(close, 15)
kst_roc3 = ta.roc(close, 20)
kst_roc4 = ta.roc(close, 30)
kst = ta.sma(kst_roc1, 10) + 2*ta.sma(kst_roc2, 10) + 3*ta.sma(kst_roc3, 10) + 4*ta.sma(kst_roc4, 15)
// 51. Percentage Price Oscillator (PPO)
ppo_line = ((ta.ema(close, 12) - ta.ema(close, 26)) / ta.ema(close, 26)) * 100
ppo_signal = ta.ema(ppo_line, 9)
ppo_histogram = ppo_line - ppo_signal
// |----- PLOT MAIN INDICATORS -----| //
// Plot key momentum indicators
plot(rsi_centered, title="01_RSI_Centered", color=color.purple, linewidth=1)
plot(stoch_centered, title="02_Stoch_Centered", color=color.blue, linewidth=1)
plot(williams_r, title="03_Williams_R", color=color.red, linewidth=1)
plot(macd_histogram, title="04_MACD_Histogram", color=color.orange, linewidth=1)
plot(cci, title="05_CCI", color=color.green, linewidth=1)
// Plot trend indicators
plot(sma_momentum, title="06_SMA_Momentum", color=color.navy, linewidth=1)
plot(ema_momentum, title="07_EMA_Momentum", color=color.maroon, linewidth=1)
plot(sar_trend, title="08_SAR_Trend", color=color.teal, linewidth=1)
plot(lr_slope, title="09_LR_Slope", color=color.lime, linewidth=1)
plot(mac, title="10_MAC", color=color.fuchsia, linewidth=1)
// Plot volatility indicators
plot(atr_pct, title="11_ATR_Pct", color=color.yellow, linewidth=1)
plot(bb_position, title="12_BB_Position", color=color.aqua, linewidth=1)
plot(kc_position, title="13_KC_Position", color=color.olive, linewidth=1)
plot(std_dev_pct, title="14_StdDev_Pct", color=color.silver, linewidth=1)
plot(bb_width, title="15_BB_Width", color=color.gray, linewidth=1)
// Plot volume indicators
plot(vroc, title="16_VROC", color=color.blue, linewidth=1)
plot(eom_sma, title="17_EOM", color=color.red, linewidth=1)
plot(vol_osc, title="18_Vol_Osc", color=color.green, linewidth=1)
plot(force_index_sma, title="19_Force_Index", color=color.orange, linewidth=1)
plot(obv, title="20_OBV", color=color.purple, linewidth=1)
// Plot additional oscillators
plot(ao, title="21_Awesome_Osc", color=color.navy, linewidth=1)
plot(cmo, title="22_CMO", color=color.maroon, linewidth=1)
plot(dpo, title="23_DPO", color=color.teal, linewidth=1)
plot(trix, title="24_TRIX", color=color.lime, linewidth=1)
plot(fisher, title="25_Fisher", color=color.fuchsia, linewidth=1)
// Plot more momentum indicators
plot(mfi_centered, title="26_MFI_Centered", color=color.yellow, linewidth=1)
plot(ac, title="27_AC", color=color.aqua, linewidth=1)
plot(ppo_pct, title="28_PPO_Pct", color=color.olive, linewidth=1)
plot(stoch_rsi_centered, title="29_StochRSI_Centered", color=color.silver, linewidth=1)
plot(klinger, title="30_Klinger", color=color.gray, linewidth=1)
// Plot trend continuation
plot(tii, title="31_TII", color=color.blue, linewidth=1)
plot(ichimoku_signal, title="32_Ichimoku_Signal", color=color.red, linewidth=1)
plot(mama_momentum, title="33_MAMA_Momentum", color=color.green, linewidth=1)
plot(zlema_momentum, title="34_ZLEMA_Momentum", color=color.orange, linewidth=1)
plot(bop, title="35_BOP", color=color.purple, linewidth=1)
// Plot volume continuation
plot(nvi, title="36_NVI", color=color.navy, linewidth=1)
plot(pvi, title="37_PVI", color=color.maroon, linewidth=1)
plot(momentum_pct, title="38_Momentum_Pct", color=color.teal, linewidth=1)
plot(roc, title="39_ROC", color=color.lime, linewidth=1)
plot(rvi, title="40_RVI", color=color.fuchsia, linewidth=1)
// Plot volatility continuation
plot(dc_position, title="41_DC_Position", color=color.yellow, linewidth=1)
plot(rvi_volatility, title="42_RVI_Volatility", color=color.aqua, linewidth=1)
plot(hv, title="43_Historical_Vol", color=color.olive, linewidth=1)
plot(gk_volatility, title="44_GK_Volatility", color=color.silver, linewidth=1)
plot(parkinson, title="45_Parkinson_Vol", color=color.gray, linewidth=1)
// Plot final oscillators
plot(rogers_satchell, title="46_RS_Volatility", color=color.blue, linewidth=1)
plot(elder_power, title="47_Elder_Power", color=color.red, linewidth=1)
plot(stc, title="48_STC", color=color.green, linewidth=1)
plot(coppock, title="49_Coppock", color=color.orange, linewidth=1)
plot(kst, title="50_KST", color=color.purple, linewidth=1)
// Plot final indicators
plot(ppo_histogram, title="51_PPO_Histogram", color=color.navy, linewidth=1)
plot(pvt, title="52_PVT", color=color.maroon, linewidth=1)
// |----- Reference Lines -----| //
hline(0, "Zero Line", color=color.gray, linestyle=hline.style_dashed, linewidth=1)
hline(50, "Midline", color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(-50, "Lower Midline", color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(25, "Upper Threshold", color=color.gray, linestyle=hline.style_dotted, linewidth=1)
hline(-25, "Lower Threshold", color=color.gray, linestyle=hline.style_dotted, linewidth=1)
// |----- Enhanced Information Table -----| //
if show_table and barstate.islast
table_position = position.top_right
table_text_size = table_size == "Tiny" ? size.tiny : table_size == "Small" ? size.small : size.normal
var table info_table = table.new(table_position, 3, 18, bgcolor=color.new(color.white, 85), border_width=1, border_color=color.gray)
// Headers
table.cell(info_table, 0, 0, 'Category', text_color=color.black, text_size=table_text_size, bgcolor=color.new(color.blue, 70))
table.cell(info_table, 1, 0, 'Indicator', text_color=color.black, text_size=table_text_size, bgcolor=color.new(color.blue, 70))
table.cell(info_table, 2, 0, 'Value', text_color=color.black, text_size=table_text_size, bgcolor=color.new(color.blue, 70))
// Key Momentum Indicators
table.cell(info_table, 0, 1, 'MOMENTUM', text_color=color.purple, text_size=table_text_size, bgcolor=color.new(color.purple, 90))
table.cell(info_table, 1, 1, 'RSI Centered', text_color=color.purple, text_size=table_text_size)
table.cell(info_table, 2, 1, str.tostring(rsi_centered, '0.00'), text_color=color.purple, text_size=table_text_size)
table.cell(info_table, 0, 2, '', text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 1, 2, 'Stoch Centered', text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 2, 2, str.tostring(stoch_centered, '0.00'), text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 0, 3, '', text_color=color.red, text_size=table_text_size)
table.cell(info_table, 1, 3, 'Williams %R', text_color=color.red, text_size=table_text_size)
table.cell(info_table, 2, 3, str.tostring(williams_r, '0.00'), text_color=color.red, text_size=table_text_size)
table.cell(info_table, 0, 4, '', text_color=color.orange, text_size=table_text_size)
table.cell(info_table, 1, 4, 'MACD Histogram', text_color=color.orange, text_size=table_text_size)
table.cell(info_table, 2, 4, str.tostring(macd_histogram, '0.000'), text_color=color.orange, text_size=table_text_size)
table.cell(info_table, 0, 5, '', text_color=color.green, text_size=table_text_size)
table.cell(info_table, 1, 5, 'CCI', text_color=color.green, text_size=table_text_size)
table.cell(info_table, 2, 5, str.tostring(cci, '0.00'), text_color=color.green, text_size=table_text_size)
// Key Trend Indicators
table.cell(info_table, 0, 6, 'TREND', text_color=color.navy, text_size=table_text_size, bgcolor=color.new(color.navy, 90))
table.cell(info_table, 1, 6, 'SMA Momentum %', text_color=color.navy, text_size=table_text_size)
table.cell(info_table, 2, 6, str.tostring(sma_momentum, '0.00'), text_color=color.navy, text_size=table_text_size)
table.cell(info_table, 0, 7, '', text_color=color.maroon, text_size=table_text_size)
table.cell(info_table, 1, 7, 'EMA Momentum %', text_color=color.maroon, text_size=table_text_size)
table.cell(info_table, 2, 7, str.tostring(ema_momentum, '0.00'), text_color=color.maroon, text_size=table_text_size)
table.cell(info_table, 0, 8, '', text_color=color.teal, text_size=table_text_size)
table.cell(info_table, 1, 8, 'SAR Trend', text_color=color.teal, text_size=table_text_size)
table.cell(info_table, 2, 8, str.tostring(sar_trend, '0'), text_color=color.teal, text_size=table_text_size)
table.cell(info_table, 0, 9, '', text_color=color.lime, text_size=table_text_size)
table.cell(info_table, 1, 9, 'Linear Regression', text_color=color.lime, text_size=table_text_size)
table.cell(info_table, 2, 9, str.tostring(lr_slope, '0.000'), text_color=color.lime, text_size=table_text_size)
// Key Volatility Indicators
table.cell(info_table, 0, 10, 'VOLATILITY', text_color=color.yellow, text_size=table_text_size, bgcolor=color.new(color.yellow, 90))
table.cell(info_table, 1, 10, 'ATR %', text_color=color.yellow, text_size=table_text_size)
table.cell(info_table, 2, 10, str.tostring(atr_pct, '0.00'), text_color=color.yellow, text_size=table_text_size)
table.cell(info_table, 0, 11, '', text_color=color.aqua, text_size=table_text_size)
table.cell(info_table, 1, 11, 'BB Position', text_color=color.aqua, text_size=table_text_size)
table.cell(info_table, 2, 11, str.tostring(bb_position, '0.00'), text_color=color.aqua, text_size=table_text_size)
table.cell(info_table, 0, 12, '', text_color=color.olive, text_size=table_text_size)
table.cell(info_table, 1, 12, 'KC Position', text_color=color.olive, text_size=table_text_size)
table.cell(info_table, 2, 12, str.tostring(kc_position, '0.00'), text_color=color.olive, text_size=table_text_size)
// Key Volume Indicators
table.cell(info_table, 0, 13, 'VOLUME', text_color=color.blue, text_size=table_text_size, bgcolor=color.new(color.blue, 90))
table.cell(info_table, 1, 13, 'Volume ROC', text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 2, 13, str.tostring(vroc, '0.00'), text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 0, 14, '', text_color=color.red, text_size=table_text_size)
table.cell(info_table, 1, 14, 'EOM', text_color=color.red, text_size=table_text_size)
table.cell(info_table, 2, 14, str.tostring(eom_sma, '0.000'), text_color=color.red, text_size=table_text_size)
// Key Oscillators
table.cell(info_table, 0, 15, 'OSCILLATORS', text_color=color.purple, text_size=table_text_size, bgcolor=color.new(color.purple, 90))
table.cell(info_table, 1, 15, 'Awesome Osc', text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 2, 15, str.tostring(ao, '0.000'), text_color=color.blue, text_size=table_text_size)
table.cell(info_table, 0, 16, '', text_color=color.red, text_size=table_text_size)
table.cell(info_table, 1, 16, 'Fisher Transform', text_color=color.red, text_size=table_text_size)
table.cell(info_table, 2, 16, str.tostring(fisher, '0.000'), text_color=color.red, text_size=table_text_size)
// Summary Statistics
table.cell(info_table, 0, 17, 'SUMMARY', text_color=color.black, text_size=table_text_size, bgcolor=color.new(color.gray, 70))
table.cell(info_table, 1, 17, 'Total Indicators: 52', text_color=color.black, text_size=table_text_size)
regime_color = rsi_centered > 10 ? color.green : rsi_centered < -10 ? color.red : color.gray
regime_text = rsi_centered > 10 ? "BULLISH" : rsi_centered < -10 ? "BEARISH" : "NEUTRAL"
table.cell(info_table, 2, 17, regime_text, text_color=regime_color, text_size=table_text_size)
This makes it the perfect “indicator backbone” for quantitative and systematic traders who want to prototype, combine, and test new regime detection models—especially in combination with the Markov Chain indicator.
How to use this script with the Markov Chain for research and backtesting:
Add the Enhanced Indicator Export to your chart.
Every calculated indicator is available as an individual data stream.
Connect the indicator(s) you want as custom input(s) to the Markov Chain’s “Custom Indicators” option.
In the Markov Chain indicator’s settings, turn ON the custom indicator mode.
For each of the three custom indicator inputs, select the exported plot from the Enhanced Export script—the menu lists all 45+ signals by name.
This creates a powerful, modular regime-detection engine where you can mix-and-match momentum, trend, volume, or custom combinations for advanced filtering.
Backtest regime logic directly.
Once you’ve connected your chosen indicators, the Markov Chain script performs regime detection (Bull/Neutral/Bear) based on your selected features—not just price returns.
The regime detection is robust, automatically normalized (using Z-score), and outputs bias (1, -1, 0) for plug-and-play integration.
Export the regime bias for programmatic use.
As described above, use input.source() in your Pine Script strategy or system and link the bias output.
You can now filter signals, control trade direction/size, or design pairs-trading that respect true, indicator-driven market regimes.
With this framework, you’re not limited to static or simplistic regime filters. You can rigorously define, test, and refine what “market regime” means for your strategies—using the technical features that matter most to you.
Optimize your signal generation by backtesting across a universe of meaningful indicator blends.
Enhance risk management with objective, real-time regime boundaries.
Accelerate your research: iterate quickly, swap indicator components, and see results with minimal code changes.
Automate multi-asset or pairs-trading by integrating regime context directly into strategy logic.
Add both scripts to your chart, connect your preferred features, and start investigating your best regime-based trades—entirely within the TradingView ecosystem.
References & Further Reading
Ang, A., & Bekaert, G. (2002). “Regime Switches in Interest Rates.” Journal of Business & Economic Statistics, 20(2), 163–182.
Hamilton, J. D. (1989). “A New Approach to the Economic Analysis of Nonstationary Time Series and the Business Cycle.” Econometrica, 57(2), 357–384.
Markov, A. A. (1906). "Extension of the Limit Theorems of Probability Theory to a Sum of Variables Connected in a Chain." The Notes of the Imperial Academy of Sciences of St. Petersburg.
Guidolin, M., & Timmermann, A. (2007). “Asset Allocation under Multivariate Regime Switching.” Journal of Economic Dynamics and Control, 31(11), 3503–3544.
Murphy, J. J. (1999). Technical Analysis of the Financial Markets. New York Institute of Finance.
Brock, W., Lakonishok, J., & LeBaron, B. (1992). “Simple Technical Trading Rules and the Stochastic Properties of Stock Returns.” Journal of Finance, 47(5), 1731–1764.
Zucchini, W., MacDonald, I. L., & Langrock, R. (2017). Hidden Markov Models for Time Series: An Introduction Using R (2nd ed.). Chapman and Hall/CRC.
On Quantitative Finance and Markov Models:
Lo, A. W., & Hasanhodzic, J. (2009). The Heretics of Finance: Conversations with Leading Practitioners of Technical Analysis. Bloomberg Press.
Patterson, S. (2016). The Man Who Solved the Market: How Jim Simons Launched the Quant Revolution. Penguin Press.
TradingView Pine Script Documentation: www.tradingview.com
TradingView Blog: “Use an Input From Another Indicator With Your Strategy” www.tradingview.com
GeeksforGeeks: “What is the Difference Between Markov Chains and Hidden Markov Models?” www.geeksforgeeks.org
What makes this indicator original and unique?
- On‑chart, real‑time Markov. The chain is drawn directly on your chart. You see the current regime, its tendency to stay (self‑loop), and the usual next step (arrows) as bars confirm.
- Source‑agnostic by design. The engine runs on any series you select via input.source() — price, your own oscillator, a composite score, anything you compute in the script.
- Automatic normalization + regime mapping. Different inputs live on different scales. The script standardizes your chosen source and maps it into clear regimes (e.g., Bull / Bear / Neutral) without you micromanaging thresholds each time.
- Rolling, bar‑by‑bar learning. Transition tendencies are computed from a rolling window of confirmed bars. What you see is exactly what the market did in that window.
- Fast experimentation. Switch the source, adjust the window, and the Markov view updates instantly. It’s a rapid way to test ideas and feel regime persistence/switch behavior.
Integrate your own signals (using input.source())
- In settings, choose the Source . This is powered by input.source() .
- Feed it price, an indicator you compute inside the script, or a custom composite series.
- The script will automatically normalize that series and process it through the Markov engine, mapping it to regimes and updating the on‑chart spheres/arrows in real time.
Credits:
Deep gratitude to @RicardoSantos for both the foundational Markov chain processing engine and inspiring open-source contributions, which made advanced probabilistic market modeling accessible to the TradingView community.
Special thanks to @Alien_Algorithms for the innovative and visually stunning 3D sphere logic that powers the indicator’s animated, regime-based visualization.
Disclaimer
This tool summarizes recent behavior. It is not financial advice and not a guarantee of future results.
Nifty Dashboard//@version=5
//Author @GODvMarkets
indicator("GOD NSE Nifty Dashboard", "Nifty Dashboard")
i_timeframe = input.timeframe("D", "Timeframe")
// if not timeframe.isdaily
// runtime.error("Please switch timeframe to Daily")
i_text_size = input.string(size.auto, "Text Size", )
//-----------------------Functions-----------------------------------------------------
f_oi_buildup(price_chg_, oi_chg_) =>
switch
price_chg_ > 0 and oi_chg_ > 0 =>
price_chg_ > 0 and oi_chg_ < 0 =>
price_chg_ < 0 and oi_chg_ > 0 =>
price_chg_ < 0 and oi_chg_ < 0 =>
=>
f_color(val_) => val_ > 0 ? color.green : val_ < 0 ? color.red : color.gray
f_bg_color(val_) => val_ > 0 ? color.new(color.green,80) : val_ < 0 ? color.new(color.red,80) : color.new(color.black,80)
f_bg_color_price(val_) =>
fg_color_ = f_color(val_)
abs_val_ = math.abs(val_)
transp_ = switch
abs_val_ > .03 => 40
abs_val_ > .02 => 50
abs_val_ > .01 => 60
=> 80
color.new(fg_color_, transp_)
f_bg_color_oi(val_) =>
fg_color_ = f_color(val_)
abs_val_ = math.abs(val_)
transp_ = switch
abs_val_ > .10 => 40
abs_val_ > .05 => 50
abs_val_ > .025 => 60
=> 80
color.new(fg_color_, transp_)
f_day_of_week(time_=time) =>
switch dayofweek(time_)
1 => "Sun"
2 => "Mon"
3 => "Tue"
4 => "Wed"
5 => "Thu"
6 => "Fri"
7 => "Sat"
//-------------------------------------------------------------------------------------
var table table_ = table.new(position.middle_center, 22, 20, border_width = 1)
var cols_ = 0
var text_color_ = color.white
var bg_color_ = color.rgb(1, 5, 19)
f_symbol(idx_, symbol_) =>
symbol_nse_ = "NSE" + ":" + symbol_
fut_cur_ = "NSE" + ":" + symbol_ + "1!"
fut_next_ = "NSE" + ":" + symbol_ + "2!"
= request.security(symbol_nse_, i_timeframe, [close, close-close , close/close -1, volume], ignore_invalid_symbol = true, lookahead = barmerge.lookahead_on)
= request.security(fut_cur_, i_timeframe, , ignore_invalid_symbol = true, lookahead = barmerge.lookahead_on)
= request.security(fut_next_, i_timeframe, , ignore_invalid_symbol = true, lookahead = barmerge.lookahead_on)
= request.security(fut_cur_ + "_OI", i_timeframe, [close, close-close ], ignore_invalid_symbol = true, lookahead = barmerge.lookahead_on)
= request.security(fut_next_ + "_OI", i_timeframe, [close, close-close ], ignore_invalid_symbol = true, lookahead = barmerge.lookahead_on)
stk_vol_ = stk_vol_nse_
fut_vol_ = fut_cur_vol_ + fut_next_vol_
fut_oi_ = fut_cur_oi_ + fut_next_oi_
fut_oi_chg_ = fut_cur_oi_chg_ + fut_next_oi_chg_
fut_oi_chg_pct_ = fut_oi_chg_ / fut_oi_
fut_stk_vol_x_ = fut_vol_ / stk_vol_
fut_vol_oi_action_ = fut_vol_ / math.abs(fut_oi_chg_)
= f_oi_buildup(chg_pct_, fut_oi_chg_pct_)
close_color_ = fut_cur_close_ > fut_vwap_ ? color.green : fut_cur_close_ < fut_vwap_ ? color.red : text_color_
if barstate.isfirst
row_ = 0, col_ = 0
table.cell(table_, col_, row_, "Symbol", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Close", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "VWAP", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Pts", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Stk Vol", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Fut Vol", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Fut/Stk Vol", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "OI Cur", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "OI Next", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "OI Cur Chg", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "OI Next Chg", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "COI ", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "COI Chg", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Vol/OI Chg", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "COI Chg%", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "Pr.Chg%", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
table.cell(table_, col_, row_, "OI Buildup", text_color = text_color_, bgcolor = bg_color_, text_size = i_text_size), col_ += 1
cell_color_ = color.white
cell_bg_color_ = color.rgb(1, 7, 24)
if barstate.islast
row_ = idx_, col_ = 0
table.cell(table_, col_, row_, str.format("{0}", symbol_), text_color = f_color(chg_pct_), bgcolor = f_bg_color_price(chg_pct_), text_size = i_text_size, text_halign = text.align_left), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#.00}", fut_cur_close_), text_color = close_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#.00}", fut_vwap_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,0.00}", chg_pts_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", stk_vol_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_vol_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,0.00}", fut_stk_vol_x_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_cur_oi_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_next_oi_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_cur_oi_chg_), text_color = f_color(fut_cur_oi_chg_), bgcolor = f_bg_color(fut_cur_oi_chg_), text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_next_oi_chg_), text_color = f_color(fut_next_oi_chg_), bgcolor = f_bg_color(fut_next_oi_chg_), text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_oi_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,#,###}", fut_oi_chg_), text_color = f_color(fut_oi_chg_), bgcolor = f_bg_color(fut_oi_chg_), text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,0.00}", fut_vol_oi_action_), text_color = cell_color_, bgcolor = cell_bg_color_, text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,0.00%}", fut_oi_chg_pct_), text_color = f_color(fut_oi_chg_pct_), bgcolor = f_bg_color_oi(fut_oi_chg_pct_), text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0,number,0.00%}", chg_pct_), text_color = f_color(chg_pct_), bgcolor = f_bg_color_price(chg_pct_), text_size = i_text_size, text_halign = text.align_right), col_ += 1
table.cell(table_, col_, row_, str.format("{0}", oi_buildup_), text_color = oi_buildup_color_, bgcolor = color.new(oi_buildup_color_,80), text_size = i_text_size, text_halign = text.align_left), col_ += 1
idx_ = 1
f_symbol(idx_, "BANKNIFTY"), idx_ += 1
f_symbol(idx_, "NIFTY"), idx_ += 1
f_symbol(idx_, "CNXFINANCE"), idx_ += 1
f_symbol(idx_, "RELIANCE"), idx_ += 1
f_symbol(idx_, "HDFC"), idx_ += 1
f_symbol(idx_, "ITC"), idx_ += 1
f_symbol(idx_, "HINDUNILVR"), idx_ += 1
f_symbol(idx_, "INFY"), idx_ += 1
Intrabar Efficiency Ratio█ OVERVIEW
This indicator displays a directional variant of Perry Kaufman's Efficiency Ratio, designed to gauge the "efficiency" of intrabar price movement by comparing the sum of movements of the lower timeframe bars composing a chart bar with the respective bar's movement on an average basis.
█ CONCEPTS
Efficiency Ratio (ER)
Efficiency Ratio was first introduced by Perry Kaufman in his 1995 book, titled "Smarter Trading". It is the ratio of absolute price change to the sum of absolute changes on each bar over a period. This tells us how strong the period's trend is relative to the underlying noise. Simply put, it's a measure of price movement efficiency. This ratio is the modulator utilized in Kaufman's Adaptive Moving Average (KAMA), which is essentially an Exponential Moving Average (EMA) that adapts its responsiveness to movement efficiency.
ER's output is bounded between 0 and 1. A value of 0 indicates that the starting price equals the ending price for the period, which suggests that price movement was maximally inefficient. A value of 1 indicates that price had travelled no more than the distance between the starting price and the ending price for the period, which suggests that price movement was maximally efficient. A value between 0 and 1 indicates that price had travelled a distance greater than the distance between the starting price and the ending price for the period. In other words, some degree of noise was present which resulted in reduced efficiency over the period.
As an example, let's say that the price of an asset had moved from $15 to $14 by the end of a period, but the sum of absolute changes for each bar of data was $4. ER would be calculated like so:
ER = abs(14 - 15)/4 = 0.25
This suggests that the trend was only 25% efficient over the period, as the total distanced travelled by price was four times what was required to achieve the change over the period.
Intrabars
Intrabars are chart bars at a lower timeframe than the chart's. Each 1H chart bar of a 24x7 market will, for example, usually contain 60 intrabars at the LTF of 1min, provided there was market activity during each minute of the hour. Mining information from intrabars can be useful in that it offers traders visibility on the activity inside a chart bar.
Lower timeframes (LTFs)
A lower timeframe is a timeframe that is smaller than the chart's timeframe. This script determines which LTF to use by examining the chart's timeframe. The LTF determines how many intrabars are examined for each chart bar; the lower the timeframe, the more intrabars are analyzed, but fewer chart bars can display indicator information because there is a limit to the total number of intrabars that can be analyzed.
Intrabar precision
The precision of calculations increases with the number of intrabars analyzed for each chart bar. As there is a 100K limit to the number of intrabars that can be analyzed by a script, a trade-off occurs between the number of intrabars analyzed per chart bar and the chart bars for which calculations are possible.
Intrabar Efficiency Ratio (IER)
Intrabar Efficiency Ratio applies the concept of ER on an intrabar level. Rather than comparing the overall change to the sum of bar changes for the current chart's timeframe over a period, IER compares single bar changes for the current chart's timeframe to the sum of absolute intrabar changes, then applies smoothing to the result. This gives an indication of how efficient changes are on the current chart's timeframe for each bar of data relative to LTF bar changes on an average basis. Unlike the standard ER calculation, we've opted to preserve directional information by not taking the absolute value of overall change, thus allowing it to be utilized as a momentum oscillator. However, by taking the absolute value of this oscillator, it could potentially serve as a replacement for ER in the design of adaptive moving averages.
Since this indicator preserves directional information, IER can be regarded as similar to the Chande Momentum Oscillator (CMO) , which was presented in 1994 by Tushar Chande in "The New Technical Trader". Both CMO and ER essentially measure the same relationship between trend and noise. CMO simply differs in scale, and considers the direction of overall changes.
█ FEATURES
Display
Three different display types are included within the script:
• Line : Displays the middle length MA of the IER as a line .
Color for this display can be customized via the "Line" portion of the "Visuals" section in the script settings.
• Candles : Displays the non-smooth IER and two moving averages of different lengths as candles .
The `open` and `close` of the candle are the longest and shortest length MAs of the IER respectively.
The `high` and `low` of the candle are the max and min of the IER, longest length MA of the IER, and shortest length MA of the IER respectively.
Colors for this display can be customized via the "Candles" portion of the "Visuals" section in the script settings.
• Circles : Displays three MAs of the IER as circles .
The color of each plot depends on the percent rank of the respective MA over the previous 100 bars.
Different colors are triggered when ranks are below 10%, between 10% and 50%, between 50% and 90%, and above 90%.
Colors for this display can be customized via the "Circles" portion of the "Visuals" section in the script settings.
With either display type, an optional information box can be displayed. This box shows the LTF that the script is using, the average number of lower timeframe bars per chart bar, and the number of chart bars that contain LTF data.
Specifying intrabar precision
Ten options are included in the script to control the number of intrabars used per chart bar for calculations. The greater the number of intrabars per chart bar, the fewer chart bars can be analyzed.
The first five options allow users to specify the approximate amount of chart bars to be covered:
• Least Precise (Most chart bars) : Covers all chart bars by dividing the current timeframe by four.
This ensures the highest level of intrabar precision while achieving complete coverage for the dataset.
• Less Precise (Some chart bars) & More Precise (Less chart bars) : These options calculate a stepped LTF in relation to the current chart's timeframe.
• Very precise (2min intrabars) : Uses the second highest quantity of intrabars possible with the 2min LTF.
• Most precise (1min intrabars) : Uses the maximum quantity of intrabars possible with the 1min LTF.
The stepped lower timeframe for "Less Precise" and "More Precise" options is calculated from the current chart's timeframe as follows:
Chart Timeframe Lower Timeframe
Less Precise More Precise
< 1hr 1min 1min
< 1D 15min 1min
< 1W 2hr 30min
> 1W 1D 60min
The last five options allow users to specify an approximate fixed number of intrabars to analyze per chart bar. The available choices are 12, 24, 50, 100, and 250. The script will calculate the LTF which most closely approximates the specified number of intrabars per chart bar. Keep in mind that due to factors such as the length of a ticker's sessions and rounding of the LTF, it is not always possible to produce the exact number specified. However, the script will do its best to get as close to the value as possible.
Specifying MA type
Seven MA types are included in the script for different averaging effects:
• Simple
• Exponential
• Wilder (RMA)
• Weighted
• Volume-Weighted
• Arnaud Legoux with `offset` and `sigma` set to 0.85 and 6 respectively.
• Hull
Weighting
This script includes the option to weight IER values based on the percent rank of absolute price changes on the current chart's timeframe over a specified period, which can be enabled by checking the "Weigh using relative close changes" option in the script settings. This places reduced emphasis on IER values from smaller changes, which may help to reduce noise in the output.
█ FOR Pine Script™ CODERS
• This script imports the recently published lower_ltf library for calculating intrabar statistics and the optimal lower timeframe in relation to the current chart's timeframe.
• This script uses the recently released request.security_lower_tf() Pine Script™ function discussed in this blog post .
It works differently from the usual request.security() in that it can only be used on LTFs, and it returns an array containing one value per intrabar.
This makes it much easier for programmers to access intrabar information.
• This script implements a new recommended best practice for tables which works faster and reduces memory consumption.
Using this new method, tables are declared only once with var , as usual. Then, on the first bar only, we use table.cell() to populate the table.
Finally, table.set_*() functions are used to update attributes of table cells on the last bar of the dataset.
This greatly reduces the resources required to render tables.
Look first. Then leap.
lower_tf█ OVERVIEW
This library is a Pine programmer’s tool containing functions to help those who use the request.security_lower_tf() function. Its `ltf()` function helps translate user inputs into a lower timeframe string usable with request.security_lower_tf() . Another function, `ltfStats()`, accumulates statistics on processed chart bars and intrabars.
█ CONCEPTS
Chart bars
Chart bars , as referred to in our publications, are bars that occur at the current chart timeframe, as opposed to those that occur at a timeframe that is higher or lower than that of the chart view.
Intrabars
Intrabars are chart bars at a lower timeframe than the chart's. Each 1H chart bar of a 24x7 market will, for example, usually contain 60 intrabars at the LTF of 1min, provided there was market activity during each minute of the hour. Mining information from intrabars can be useful in that it offers traders visibility on the activity inside a chart bar.
Lower timeframes (LTFs)
A lower timeframe is a timeframe that is smaller than the chart's timeframe. This framework exemplifies how authors can determine which LTF to use by examining the chart's timeframe. The LTF determines how many intrabars are examined for each chart bar; the lower the timeframe, the more intrabars are analyzed.
Intrabar precision
The precision of calculations increases with the number of intrabars analyzed for each chart bar. As there is a 100K limit to the number of intrabars that can be analyzed by a script, a trade-off occurs between the number of intrabars analyzed per chart bar and the chart bars for which calculations are possible.
█ `ltf()`
This function returns a timeframe string usable with request.security_lower_tf() . It calculates the returned timeframe by taking into account a user selection between eight different calculation modes and the chart's timeframe. You send it the user's selection, along with the text corresponding to the eight choices from which the user has chosen, and the function returns a corresponding LTF string.
Because the function processes strings and doesn't require recalculation on each bar, using var to declare the variable to which its result is assigned will execute the function only once on bar zero and speed up your script:
var string ltfString = ltf(ltfModeInput, LTF1, LTF2, LTF3, LTF4, LTF5, LTF6, LTF7, LTF8)
The eight choices users can select from are of two types: the first four allow a selection from the desired amount of chart bars to be covered, the last four are choices of a fixed number of intrabars to be analyzed per chart bar. Our example code shows how to structure your input call and then make the call to `ltf()`. By changing the text associated with the `LTF1` to `LTF8` constants, you can tailor it to your preferences while preserving the functionality of `ltf()` because you will be sending those string constants as the function's arguments so it can determine the user's selection. The association between each `LTFx` constant and its calculation mode is fixed, so the order of the arguments is important when you call `ltf()`.
These are the first four modes and the `LTFx` constants corresponding to each:
Covering most chart bars (least precise) — LTF1
Covers all chart bars. This is accomplished by dividing the current timeframe in seconds by 4 and converting that number back to a string in timeframe.period format using secondsToTfString() . Due to the fact that, on premium subscriptions, the typical historical bar count is between 20-25k bars, dividing the timeframe by 4 ensures the highest level of intrabar precision possible while achieving complete coverage for the entire dataset with the maximum allowed 100K intrabars.
Covering some chart bars (less precise) — LTF2
Covering less chart bars (more precise) — LTF3
These levels offer a stepped LTF in relation to the chart timeframe with slightly more, or slightly less precision. The stepped lower timeframe tiers are calculated from the chart timeframe as follows:
Chart Timeframe Lower Timeframe
Less Precise More Precise
< 1hr 1min 1min
< 1D 15min 1min
< 1W 2hr 30min
> 1W 1D 60min
Covering the least chart bars (most precise) — LTF4
Analyzes the maximum quantity of intrabars possible by using the 1min LTF, which also allows the least amount of chart bars to be covered.
The last four modes allow the user to specify a fixed number of intrabars to analyze per chart bar. Users can choose from 12, 24, 50 or 100 intrabars, respectively corresponding to the `LTF5`, `LTF6`, `LTF7` and `LTF8` constants. The value is a target; the function will do its best to come up with a LTF producing the required number of intrabars. Because of considerations such as the length of a ticker's session, rounding of the LTF to the closest allowable timeframe, or the lowest allowable timeframe of 1min intrabars, it is often impossible for the function to find a LTF producing the exact number of intrabars. Requesting 100 intrabars on a 60min chart, for example, can only produce 60 1min intrabars. Higher chart timeframes, tickers with high liquidity or 24x7 markets will produce optimal results.
█ `ltfStats()`
`ltfStats()` returns statistics that will be useful to programmers using intrabar inspection. By analyzing the arrays returned by request.security_lower_tf() in can determine:
• intrabarsInChartBar : The number of intrabars analyzed for each chart bar.
• chartBarsCovered : The number of chart bars where intrabar information is available.
• avgIntrabars : The average number of intrabars analyzed per chart bar. Events like holidays, market activity, or reduced hours sessions can cause the number of intrabars to vary, bar to bar.
The function must be called on each bar to produce reliable results.
█ DEMONSTRATION CODE
Our example code shows how to provide users with an input from which they can select a LTF calculation mode. If you use this library's functions, feel free to reuse our input setup code, including the tooltip providing users with explanations on how it works for them.
We make a simple call to request.security_lower_tf() to fetch the close values of intrabars, but we do not use those values. We simply send the returned array to `ltfStats()` and then plot in the indicator's pane the number of intrabars examined on each bar and its average. We also display an information box showing the user's selection of the LTF calculation mode, the resulting LTF calculated by `ltf()` and some statistics.
█ NOTES
• As in several of our recent publications, this script uses secondsToTfString() to produce a timeframe string in timeframe.period format from a timeframe expressed in seconds.
• The script utilizes display.data_window and display.status_line to restrict the display of certain plots.
These new built-ins allow coders to fine-tune where a script’s plot values are displayed.
• We implement a new recommended best practice for tables which works faster and reduces memory consumption.
Using this new method, tables are declared only once with var , as usual. Then, on bar zero only, we use table.cell() calls to populate the table.
Finally, table.set_*() functions are used to update attributes of table cells on the last bar of the dataset.
This greatly reduces the resources required to render tables. We encourage all Pine Script™ programmers to do the same.
Look first. Then leap.
█ FUNCTIONS
The library contains the following functions:
ltf(userSelection, choice1, choice2, choice3, choice4, choice5, choice6, choice7, choice8)
Selects a LTF from the chart's TF, depending on the `userSelection` input string.
Parameters:
userSelection : (simple string) User-selected input string which must be one of the `choicex` arguments.
choice1 : (simple string) Input selection corresponding to "Least precise, covering most chart bars".
choice2 : (simple string) Input selection corresponding to "Less precise, covering some chart bars".
choice3 : (simple string) Input selection corresponding to "More precise, covering less chart bars".
choice4 : (simple string) Input selection corresponding to "Most precise, 1min intrabars".
choice5 : (simple string) Input selection corresponding to "~12 intrabars per chart bar".
choice6 : (simple string) Input selection corresponding to "~24 intrabars per chart bar".
choice7 : (simple string) Input selection corresponding to "~50 intrabars per chart bar".
choice8 : (simple string) Input selection corresponding to "~100 intrabars per chart bar".
Returns: (simple string) A timeframe string to be used with `request.security_lower_tf()`.
ltfStats()
Returns statistics about analyzed intrabars and chart bars covered by calls to `request.security_lower_tf()`.
Parameters:
intrabarValues : (float [ ]) The ID of a float array containing values fetched by a call to `request.security_lower_tf()`.
Returns: A 3-element tuple: [ (series int) intrabarsInChartBar, (series int) chartBarsCovered, (series float) avgIntrabars ].